discord.client使用静态令牌登录



我遇到了一个问题,因为最近启动了我的机器人,我一直收到这个错误消息,我不知道这个错误可能意味着什么。我还试图重置我的机器人令牌,并制作了一个新的机器人,但从那以后什么都没有改变。特别是静态标记是什么意思,我查了那个词,但什么也没找到,我会很高兴得到有用的答案。

错误:

Traceback (most recent call last):
File "C:Python39libsite-packagesdiscordhttp.py", line 300, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "C:Python39libsite-packagesdiscordhttp.py", line 254, in request
raise HTTPException(r, data)
discord.errors.HTTPException: 401 Unauthorized (error code: 0): 401: Unauthorized
The above exception was the direct cause of the following exception:
Traceback (most recent call last):
File "C:UsersLöpoldPycharmProjectspythonProject1main.py", line 59, in <module>
bot.run(token)
File "C:Python39libsite-packagesdiscordclient.py", line 723, in run
return future.result()
File "C:Python39libsite-packagesdiscordclient.py", line 702, in runner
await self.start(*args, **kwargs)
File "C:Python39libsite-packagesdiscordclient.py", line 665, in start
await self.login(*args, bot=bot)
File "C:Python39libsite-packagesdiscordclient.py", line 511, in login
await self.http.static_login(token.strip(), bot=bot)
File "C:Python39libsite-packagesdiscordhttp.py", line 304, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
Exception ignored in: <function _ProactorBasePipeTransport.__del__ at 0x000001F03CF823A0>
Traceback (most recent call last):
File "C:Python39libasyncioproactor_events.py", line 116, in __del__
self.close()
File "C:Python39libasyncioproactor_events.py", line 108, in close
self._loop.call_soon(self._call_connection_lost, None)
File "C:Python39libasynciobase_events.py", line 746, in call_soon
self._check_closed()
File "C:Python39libasynciobase_events.py", line 510, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```

这是我最初的代码:

import json
import asyncio
import datetime
import discord
from discord.ext import commands
from io import BytesIO
from numpy import resize

client = commands.Bot(command_prefix=".", intents=discord.Intents.all())
prefix = "."


async def status_task():
while True:
await client.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name="Leon"),
status=discord.Status.online)
await asyncio.sleep(2)
await client.change_presence(
activity=discord.Activity(
type=discord.ActivityType.watching,
name=f"A master at work"),
status=discord.Status.online)
await asyncio.sleep(2)

@client.command()
async def helps(ctx):
await ctx.message.delete()
embed = discord.Embed(title="E", description=f"""
`███████╗██████╗ ██████╗  ██████╗ ██████╗ 
██╔════╝██╔══██╗██╔══██╗██╔═══██╗██╔══██╗
█████╗  ██████╔╝██████╔╝██║   ██║██████╔╝
██╔══╝  ██╔══██╗██╔══██╗██║   ██║██╔══██╗
███████╗██║  ██║██║  ██║╚██████╔╝██║  ██║
╚══════╝╚═╝  ╚═╝╚═╝  ╚═╝ ╚═════╝ ╚═╝  ╚═╝`
""", color=discord.Colour.blue(), timestamp=datetime.datetime.utcnow(), inline="true")
embed.set_footer(icon_url=ctx.author.avatar_url)
await ctx.channel.send(embed=embed)
@client.command()
async def createchannel(ctx, channelName):
guild = ctx.guild
embed = discord.Embed(title="Succesfully created a new Channel", description="{} has been created".format(channelName))
if ctx.author.guild_permissions.manage_channels:
await guild.create_text_channel(name='{}'.format(channelName))
await ctx.send(embed=embed)

client.run('')

我不知道问题出在哪里,也许有人能帮我。

此错误表示您传递的字符串不是有效的令牌。请检查您的代币是否正确。如果您忘记了您的代币,您可以在开发者门户创建一个新的代币。

401错误表示您未经授权。如果你还没有用你的新密钥更新你的环境变量,我会这么做。除此之外,请尝试重新启动您的终端

最新更新