如何从令牌中获取用户 ID

时间:2021-04-06 10:57:25

标签: python discord.py

我正在创建一些东西,我想要它,以便当您键入 !token <token> 时,它会找到属于该令牌的名称和头像。

问题:我无法运行另一个机器人,我收到了这个愚蠢的错误:

handle: <Handle <TaskStepMethWrapper object at 0x7f8e24068220>()>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <ClientEventTask state=pending event=on_message coro=<bound method BotBase.on_message of <discord.ext.commands.bot.Bot object at 0x7f8e30184b50>>> while another task <ClientEventTask state=pending event=on_message coro=<bound method BotBase.on_message of <discord.ext.commands.bot.Bot object at 0x7f8e30184b50>>> is being executed.
Exception in callback <TaskStepMethWrapper object at 0x7f8e24068d90>()
handle: <Handle <TaskStepMethWrapper object at 0x7f8e24068d90>()>
Traceback (most recent call last):
  File "/usr/lib/python3.8/asyncio/events.py", line 81, in _run
    self._context.run(self._callback, *self._args)
RuntimeError: Cannot enter into task <ClientEventTask state=pending event=on_message coro=<bound method BotBase.on_message of <discord.ext.commands.bot.Bot object at 0x7f8e26333b50>>> while another task <ClientEventTask state=pending event=on_message coro=<bound method BotBase.on_message of <discord.ext.commands.bot.Bot object at 0x7f8e30184b50>>> is being executed.

如果无法从令牌中获取用户 ID,我将完全理解,如果不能,如果您知道如何仅删除该错误,那将是很好的代码:

@client.command():
async def token(ctx, token):
  client2.run(value)
  await client2.wait_until_ready()
  await ctx.send(client.user.id)
  client2.stop()

请注意:这不是原始代码,我不希望任何人窃取我的原始代码,这完全相同,除了没有嵌入和我认为无关紧要的消息编辑。

1 个答案:

答案 0 :(得分:0)

首先,您不能同时运行 2 个机器人。其次,使用 !token 并与其他人共享您的令牌是非常危险的。第三,您永远不应该访问其他人的令牌。它使您可以完全访问该帐户。