問題描述
我在 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.
這篇關于傳遞了不正確的令牌的文章就介紹到這了,希望我們推薦的答案對大家有所幫助,也希望大家多多支持html5模板網!