[英]My discord bot have a error “Traceback (most recent call last):”
[英]Python Traceback (most recent call last) Issue while coding discord bot
最近做了一些随机编码,我不断收到此错误消息。 我该怎么办?
错误: https://i.stack.imgur.com/CSSMu.png
编码:
import discord
import os
client = discord.Client()
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
if message.author == client.user:
return
if message.content.startswith('sleep start'):
await message.channel.send('Welcome to Sleepy Quest! A world of dumb adventures now await you!')
client.run(os.getenv('Discord Bot Token (Deleted for private stuff)'))
无论如何,您在该屏幕截图中泄露了令牌。 现在重置它。
欺骗中没有解决它,但问题是您的“关键”实际上是令牌本身,而不是变量。 如果找不到,它将返回None
, discord.py
试图将其解释为字符串,从而导致该错误。
由于无论如何您都在粘贴令牌,因此只需正常传递:
client.run('xxxxxxxxxxxxxxxxxxxxxxxx.xxxxxx.xxxxxxxxxxxxxxxxxxxxxxxxxxx')
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.