首页
学习
活动
专区
圈层
工具
发布
首页
学习
活动
专区
圈层
工具
MCP广场
社区首页 >问答首页 >使用静态令牌登录discord.client

使用静态令牌登录discord.client
EN

Stack Overflow用户
提问于 2022-08-31 17:11:21
回答 2查看 3.3K关注 0票数 0

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

错误:

代码语言:javascript
运行
复制
Traceback (most recent call last):
  File "C:\Python39\lib\site-packages\discord\http.py", line 300, in static_login
    data = await self.request(Route('GET', '/users/@me'))
  File "C:\Python39\lib\site-packages\discord\http.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:\Users\Löpold\PycharmProjects\pythonProject1\main.py", line 59, in <module>
    bot.run(token)
  File "C:\Python39\lib\site-packages\discord\client.py", line 723, in run
    return future.result()
  File "C:\Python39\lib\site-packages\discord\client.py", line 702, in runner
    await self.start(*args, **kwargs)
  File "C:\Python39\lib\site-packages\discord\client.py", line 665, in start
    await self.login(*args, bot=bot)
  File "C:\Python39\lib\site-packages\discord\client.py", line 511, in login
    await self.http.static_login(token.strip(), bot=bot)
  File "C:\Python39\lib\site-packages\discord\http.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:\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
    self.close()
  File "C:\Python39\lib\asyncio\proactor_events.py", line 108, in close
    self._loop.call_soon(self._call_connection_lost, None)
  File "C:\Python39\lib\asyncio\base_events.py", line 746, in call_soon
    self._check_closed()
  File "C:\Python39\lib\asyncio\base_events.py", line 510, in _check_closed
    raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed```

这是我的原始代码:

代码语言:javascript
运行
复制
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('')

我不知道是什么问题,也许有人能帮我。

EN

回答 2

Stack Overflow用户

发布于 2022-08-31 17:35:20

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

票数 1
EN

Stack Overflow用户

发布于 2022-08-31 17:19:42

401错误意味着你未经授权。如果您没有用新键更新您的环境变量,我将这样做。除此之外,试着重新启动终端。

票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/73559546

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档