Python discord bot 错误 client.run 不工作
Python discord bot error client.run not working
我写了这段代码:
import discord
import os
async def on_ready():
await client.change_presence(game=discord.Game(name=" dm for support ;)"))
client.run("<TOKEN>")
TOKEN = os.environ['TOKEN']
但我一直收到此错误
Traceback (most recent call last):
File "main.py", line 10, in
client.run("")
NameError: name 'client' is not defined
您尚未创建正在使用的客户端对象,您可以在代码中使用客户端对象之前创建一个:
client = discord.Client()
我写了这段代码:
import discord
import os
async def on_ready():
await client.change_presence(game=discord.Game(name=" dm for support ;)"))
client.run("<TOKEN>")
TOKEN = os.environ['TOKEN']
但我一直收到此错误
Traceback (most recent call last):
File "main.py", line 10, in
client.run("")NameError: name 'client' is not defined
您尚未创建正在使用的客户端对象,您可以在代码中使用客户端对象之前创建一个:
client = discord.Client()