不正确的令牌已通过discord.py

时间:2017-11-22 19:18:27

标签: python

所以我实际上正在尝试制作一个机器人,它将嵌入服务器发送,或者不会发送,我会做命令,它会在服务器中发送嵌入消息。但是当我尝试运行机器人时,我不断收到错误。顺便说一句,我正在使用Pycharm,无论如何看看。

bot_prefix = "`"
bot = commands.Bot(command_prefix=bot_prefix)


@bot.event
async def on_event():
    print('Logged in as')
    print(bot.user.name)
    print(bot.user.id)
    print("---------")


@bot.command(pass_context=True)
async def embed(ctx):
        embed = discord.Embed(
            title="Blog Post # 2",
            url="https://darksiderclan2.weebly.com/uploads/1/1/4/7/114760003/published/battle.png?1510944203/n",
            color=0xffff00,
            description="Aquí hay una segunda publicación de blog para su sitio web/n",
            )
        await bot.say(embed=embed)

bot.run('TOKEN')

这就是我的代码,现在我得到的错误是:

`C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\python.exe "C:/Users/Default.Default-PC/Desktop/Chief Bot.py"
Traceback (most recent call last):
  File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\http.py", line 252, in static_login
    data = yield from self.request(Route('GET', '/users/@me'))
  File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\http.py", line 212, in request
    raise HTTPException(r, data)
discord.errors.HTTPException: UNAUTHORIZED (status code: 401): 401: Unauthorized

The above exception was the direct cause of the following exception:

Traceback (most recent call last): File "C:/Users/Default.Default-PC/Desktop/Chief Bot.py", line 27, in bot.run('WPUi5O1UAxfQiiK2GDz9cktDO82ApySM') File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 567, in run return task.result() File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\asyncio\futures.py", line 274, in result raise self._exception File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 487, in _silence_gathered fut.result() File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\asyncio\futures.py", line 274, in result raise self._exception File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\asyncio\tasks.py", line 239, in _step result = coro.send(None) File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 474, in start yield from self.login(*args, bot=bot) File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\client.py", line 352, in login yield from self.http.static_login(token, bot=bot) File "C:\Users\Default.Default-PC\AppData\Local\Programs\Python\Python35-32\lib\site-packages\discord\http.py", line 256, in static_login raise LoginFailure('Improper token has been passed.') from e discord.errors.LoginFailure: Improper token has been passed.

Process finished with exit code 1`

请告诉我有什么问题?我以前在制作机器人时不习惯这个错误。

1 个答案:

答案 0 :(得分:1)

我知道此线程很旧,但对于仍在寻找答案的任何人(因为这是搜索时弹出的第一件事)

他可能使用了客户端令牌而不是bot令牌来获取bot令牌,您必须转到Discord Delevoper门户并单击左侧的“ Bot”选项卡,然后单击“单击以Bot名称的输入部分下的“揭示令牌”,将其复制并插入您的代码中。为我工作。