Discord Bot funktioniert nicht
Verfasst: Sonntag 28. Mai 2023, 11:29
Moin moin,
Ich bin neu in Python und meine Tochter wollte ein Discord Bot programmieren!
Der funktioniert aber nicht so wie er soll! Genauer gesagt, der Bot geht gar nicht erst online!
Das ist der Code zum Bot!
##############################################################################
import discord
from discord.ext import commands
import os
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>',intents=intents)
@bot.command()
async def ping(ctx):
await ctx.send('pong')
TOKEN = os.environ['TOKEN']
bot.run("TOKEN")
###############################################################################
Wenn ich den Code ausführe erhalte ich diese Ausgabe:
INFO discord.client logging in using static token
Traceback (most recent call last):
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/http.py", line 801, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/http.py", line 744, 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 "main.py", line 15, in <module>
bot.run("TOKEN")
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 612, in login
data = await self.http.static_login(token)
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/http.py", line 805, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
################################################################################################
Kann mir jemand sagen was ich Falsch gemacht habe?
PS: Ich habe Replit benutzt!
Ich bin neu in Python und meine Tochter wollte ein Discord Bot programmieren!
Der funktioniert aber nicht so wie er soll! Genauer gesagt, der Bot geht gar nicht erst online!
Das ist der Code zum Bot!
##############################################################################
import discord
from discord.ext import commands
import os
intents = discord.Intents.default()
intents.message_content = True
bot = commands.Bot(command_prefix='>',intents=intents)
@bot.command()
async def ping(ctx):
await ctx.send('pong')
TOKEN = os.environ['TOKEN']
bot.run("TOKEN")
###############################################################################
Wenn ich den Code ausführe erhalte ich diese Ausgabe:
INFO discord.client logging in using static token
Traceback (most recent call last):
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/http.py", line 801, in static_login
data = await self.request(Route('GET', '/users/@me'))
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/http.py", line 744, 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 "main.py", line 15, in <module>
bot.run("TOKEN")
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 860, in run
asyncio.run(runner())
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/runners.py", line 44, in run
return loop.run_until_complete(main)
File "/nix/store/hd4cc9rh83j291r5539hkf6qd8lgiikb-python3-3.10.8/lib/python3.10/asyncio/base_events.py", line 649, in run_until_complete
return future.result()
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 849, in runner
await self.start(token, reconnect=reconnect)
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 777, in start
await self.login(token)
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/client.py", line 612, in login
data = await self.http.static_login(token)
File "/home/runner/dcBot/venv/lib/python3.10/site-packages/discord/http.py", line 805, in static_login
raise LoginFailure('Improper token has been passed.') from exc
discord.errors.LoginFailure: Improper token has been passed.
################################################################################################
Kann mir jemand sagen was ich Falsch gemacht habe?
PS: Ich habe Replit benutzt!