传递了不正确的令牌

Improper token passed(传递了不正确的令牌)
本文介绍了传递了不正确的令牌的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着跟版网的小编来一起学习吧!

问题描述

限时送ChatGPT账号..

我在 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.

这篇关于传递了不正确的令牌的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持跟版网!

本站部分内容来源互联网,如果有图片或者内容侵犯了您的权益,请联系我们,我们会在确认后第一时间进行删除!

相关文档推荐

How do I make a list of all members in a discord server using discord.py?(如何使用 discord.py 列出不和谐服务器中的所有成员?)
how to change discord.py bot activity(如何更改 discord.py 机器人活动)
Issues with getting VoiceChannel.members and Guild.members to return a full list(让 VoiceChannel.members 和 Guild.members 返回完整列表的问题)
Add button components to a message (discord.py)(将按钮组件添加到消息(discord.py))
on_message() and @bot.command issue(on_message() 和@bot.command 问题)
How to edit a message in discord.py(如何在 discord.py 中编辑消息)