Improper token passed(传递了不正确的令牌)
问题描述
我在 YouTube 上关注 Python Discord 机器人的基本教程,我的代码在下面.它说:
I'm following a basic tutorial for a Python Discord bot on YouTube and my code is underneath. It says:
discord.errors.LoginFailure:通过了不正确的令牌.
discord.errors.LoginFailure: Improper token has been passed.
在任何人问之前,是的,我已经输入了机器人令牌,而不是 id 或秘密.
Before anyone asks, yes I have put in the bot token, not the id or secret.
import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time
Client = discord.Client()
client = commands.Bot(command_prefix = "!")
@client.event
async def on_ready():
print("Bot is ready!")
@client.event
async def on_message(message):
if message.content == "cookie":
await client.send_message(message.channel, ":cookie:")
client.run("token is here")
推荐答案
确保你拿到了Token"来自机器人"Discord 开发站点中的页面,而不是秘密"页面.来自一般信息";页面.
Make sure you grab the "Token" from the "Bot" page in the Discord development site, rather than the "Secret" from the "General Information" page.
我遇到了同样的问题.通过使用 Discord 应用页面中的正确令牌解决了我的问题.我使用的是秘密".从一般信息"页面(它为我在原始帖子中生成错误)而不是令牌"页面来自机器人"页面.
I was having the same problem. My issue was solved by using the correct token from the Discord app page. I was using the "Secret" from the 'General Information' page (which generated the error in the original post for me) instead of the "Token" from the "Bot" page.
正如 sheneb 在对此的评论中所说,这个答案(可能)不会帮助 OP(因为现在的问题是在有人问之前,是的,我已经输入了 bot 令牌,而不是 id 或秘密".).但是,我在搜索答案时发现了这个问题/页面,我的问题通过这些信息得到了解决.
As sheneb said in the comment to this, this answer (probably) won't help the OP (since the question now says "Before anyone asks, yes I have put in the bot token, not the id or secret"). However, I found this question/page when searching for the answer, and my issue was solved with this information.
这篇关于传递了不正确的令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:传递了不正确的令牌
基础教程推荐
- matplotlib 设置 yaxis 标签大小 2022-01-01
- Python 中是否有任何支持将长字符串转储为块文字或折叠块的 yaml 库? 2022-01-01
- Python,确定字符串是否应转换为 Int 或 Float 2022-01-01
- 比较两个文本文件以找出差异并将它们输出到新的文本文件 2022-01-01
- 究竟什么是“容器"?在蟒蛇?(以及所有的 python 容器类型是什么?) 2022-01-01
- kivy 应用程序中的一个简单网页作为小部件 2022-01-01
- 对多索引数据帧的列进行排序 2022-01-01
- 在 Django Admin 中使用内联 OneToOneField 2022-01-01
- Kivy 使用 opencv.调整图像大小 2022-01-01
- 在 Python 中将货币解析为数字 2022-01-01
