Warum heißt es "Unangemessenes Token wurde bestanden", als er versuchte, einen Bot zu betreiben?Python

Python-Programme
Guest
 Warum heißt es "Unangemessenes Token wurde bestanden", als er versuchte, einen Bot zu betreiben?

Post by Guest »

Immer wenn ich versuche, meinen Code auszuführen, sagt es mir, dass er sich anmeldet, und dann hat er einen Benutzeragenten gefunden, nach dem es mir einen Fehler bietet. Wann immer ich versuchte, genau den gleichen Code für ein normales Discord -Konto zu verwenden, hat es vollkommen in Ordnung funktioniert, aber ich kann es nicht zum Laufen bringen, während ich eine offizielle Diskord -Anwendung verwendet habe. < /P>
unten ist mein Code < /p>

Code: Select all

import discord
from discord.ext import commands
# in player.py I have commented out import audioop in line 28

prefix = ["Yombot, ", "YomBot, ", "Yb, ", "YB, "]

token = "token from bot tab in discord developer portal"
client = commands.Bot(command_prefix=prefix, bot=True)

@client.event
async def on_ready():
print(f'Yombot has connected to Discord!')

client.run(token)
< /code>

oben habe ich versucht < /p>

Was ich erwartet habe:
Damit sich der Bot anmelden und operativ sein kann < /p>

Was ist geschehen:
Ich habe den Fehler (s) < /p> < Br />E:\yombot\venv\Scripts\python.exe E:\yombot\main.py
2025-02-10 00:23:55 INFO     discord.client Logging in using static token.
2025-02-10 00:23:56 INFO     discord.http Found user agent Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/133.0.0.0 Safari/537.36, build number 366955.
Traceback (most recent call last):
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\http.py", line 994, in static_login
data = await self.get_me()
^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\http.py", line 838, in request
raise HTTPException(response, 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 "E:\yombot\main.py", line 19, in 
client.run(token)
~~~~~~~~~~^^^^^^^
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\client.py", line 938, in run
asyncio.run(runner())
~~~~~~~~~~~^^^^^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.752.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 195, in run
return runner.run(main)
~~~~~~~~~~^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.752.0_x64__qbz5n2kfra8p0\Lib\asyncio\runners.py", line 118, in run
return self._loop.run_until_complete(task)
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~^^^^^^
File "C:\Program Files\WindowsApps\PythonSoftwareFoundation.Python.3.13_3.13.752.0_x64__qbz5n2kfra8p0\Lib\asyncio\base_events.py", line 725, in run_until_complete
return future.result()
~~~~~~~~~~~~~^^
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\client.py", line 927, in runner
await self.start(token, reconnect=reconnect)
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\client.py", line 857, in start
await self.login(token)
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\client.py", line 698, in login
data = await state.http.static_login(token.strip())
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\me\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.13_qbz5n2kfra8p0\LocalCache\local-packages\Python313\site-packages\discord\http.py", line 998, in static_login
raise LoginFailure('Improper token has been passed') from exc
discord.errors.LoginFailure: Improper token has been passed

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post