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.
这篇关于传递了不正确的令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持编程学习网!
本文标题为:传递了不正确的令牌


基础教程推荐
- Dask.array.套用_沿_轴:由于额外的元素([1]),使用dask.array的每一行作为另一个函数的输入失败 2022-01-01
- 如何在海运重新绘制中自定义标题和y标签 2022-01-01
- 何时使用 os.name、sys.platform 或 platform.system? 2022-01-01
- 在 Python 中,如果我在一个“with"中返回.块,文件还会关闭吗? 2022-01-01
- 筛选NumPy数组 2022-01-01
- 使用PyInstaller后在Windows中打开可执行文件时出错 2022-01-01
- Python kivy 入口点 inflateRest2 无法定位 libpng16-16.dll 2022-01-01
- 线程时出现 msgbox 错误,GUI 块 2022-01-01
- 如何让 python 脚本监听来自另一个脚本的输入 2022-01-01
- 用于分类数据的跳跃记号标签 2022-01-01