Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
343 views
in Technique[技术] by (71.8m points)

discord.py - 范围无效? Discord.py,Gspread(Invalid Scope? Discord.py, Gspread)

import discord
from discord.ext import commands
import gspread
from oauth2client.service_account import ServiceAccountCredentials
from pprint import pprint

scope = ["""https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/sprea...,"https://www.googleapis.com/auth/drive...","https://www.googleapis.com/auth/drive"""]

creds = ServiceAccountCredentials.from_json_keyfile_name("creds.json", scope)

client = gspread.authorize(creds)

sheet = client.open("NYRP Clock Ins").sheet1  # Open the spreadhseet

data = sheet.get_all_records()  # Get a list of all records

row = sheet.row_values(3)  # Get a specific row
col = sheet.col_values(3)  # Get a specific column
cell = sheet.cell(1,2).value  # Get the value of a specific cell

insertRow = ["hello", 5, "red", "blue"]
sheet.add_rows(insertRow, 4)  # Insert the list as a row at index 4

sheet.update_cell(2,2, "CHANGED")  # Update one cell

numRows = sheet.row_count  # Get the number of rows in the sheet

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged in as')
        print(self.user.name)
        print(self.user.id)
        print('------')

    async def on_message(self, message):
        # we do not want the bot to reply to itself
        if message.author.id == self.user.id:
            return

        if message.content.startswith('.clock in'):
            embed = discord.Embed(title='BCSO', description='Succesfully Clocked In', color=0x5ed623)
            embed.add_field(name='.clock out', value='Clocks out')
            await message.channel.send(content=None, embed=embed,)
            insertRow = ["hello", 5, "red", "blue"]
            sheet.add_rows(insertRow, 4)  # Insert the list as a row at index 4


        if message.content.startswith('.clock out'):
            embed = discord.Embed(title='BCSO', description='Succesfully Clocked Out', color=0xef210a)
            embed.add_field(name='.clock in', value='Clocks In')
            await message.channel.send(content=None, embed=embed,)

invalid_scope: https://spreadsheets.google.com/feeds",'https://www.googleapis.com/auth/sprea...,"https://www.googleapis.com/auth/drive...","https://www.googleapis.com/auth /drive is not a valid audience string.

(invalid_scope: https://spreadsheets.google.com/feeds“,'https://www.googleapis.com/auth/sprea ...,” https://www.googleapis.com/auth/drive ... “,” https://www.googleapis.com/auth /驱动器不是有效的受众字符串。)

I get the above error message when i try to run the bot and cant find a fix

(当我尝试运行bot并找不到修复程序时收到上述错误消息)

  ask by R.Peter translate from so

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Reply

0 votes
by (71.8m points)
等待大神答复

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...