[英]Discord.py VSCode error when running my code: NameError: name 'TOKEN' is not defined
so i was trying to run my discord bot and it said NameError: name 'TOKEN' is not defined所以我试图运行我的 discord 机器人,它说 NameError: name 'TOKEN' is not defined
import discord
client = discord.Client()
client.run (TOKEN)
TOKEN = "MTA1NzMyOTgxNjM1NDk1MTMwOA.GReZn2.Or8nNzABZL_VzBmJch3x0RsvjuuCAICHE8r7HM"
this is my code tell me what is wrong这是我的代码 告诉我哪里出了问题
Try defining the token before you use it.在使用之前尝试定义令牌。
import discord
client = discord.Client()
TOKEN = "Insert Token Here"
client.run(TOKEN)
You defined your token after you referenced it.您在引用令牌后定义了令牌。 Put the token definition before
client.run(token)
.将令牌定义放在
client.run(token)
之前。
import discord
client = discord.Client()
TOKEN = 'token'
Client.run(TOKEN)
Also, even though you reset your token, we request that you obfuscate it anyway.此外,即使您重置了您的令牌,我们仍然要求您混淆它。 It is for security and readability.
这是为了安全性和可读性。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.