#đź”’ hi pls help my bot doesn't want to work even chatgpt can't find the problem
10 messages · Page 1 of 1 (latest)
@stable drum
Remember to:
- Ask your Python question, not if you can ask or if there's an expert who can help.
- Show a code sample as text (rather than a screenshot) and the error message, if you've got one.
- Explain what you expect to happen and what actually happens.
:warning: Do not pip install anything that isn't related to your question, especially if asked to over DMs.
import discord
from discord.ext import commands
import os
Lecture du token Ă partir du fichier config.txt
with open('config.txt', 'r') as file:
token = file.read().strip()
Configuration des intents
intents = discord.Intents.default()
intents.messages = True
intents.guilds = True
intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
print(f"Connecté en tant que {bot.user}")
try:
bot.load_extension("commands.ping") # Charger l'extension ping directement ici
print("Commande 'ping' chargée.") # Vérification du log de débogage
except Exception as e:
print(f"Erreur lors du chargement de la commande ping : {e}")
Lancer le bot
bot.run(token)
Hey @stable drum!
It looks like you're trying to paste code into this channel.
Discord has support for Markdown, which allows you to post code with full syntax highlighting. Please use these whenever you paste code, as this helps improve the legibility and makes it easier for us to help you.
To do this, use the following method:
```py
print('Hello, world!')
```
This will result in the following:
print('Hello, world!')```
You can **edit your original message** to correct your code block.
from discord.ext import commands
class Ping(commands.Cog):
def init(self, bot):
self.bot = bot
@commands.command()
async def ping(self, ctx):
"""Répond avec 'Pong!'."""
await ctx.send("Pong!")
def setup(bot):
print("Ajout du cog Ping...") # Ajout d'un log pour débogage
bot.add_cog(Ping(bot)) # Ajout de la commande Ping au bot
here is the source code
[2024-12-23 01
50] [INFO ] discord.client: logging in using static token
[2024-12-23 01
51] [INFO ] discord.gateway: Shard ID None has connected to Gateway (Session ID: e169a0ee9d15c65f26f8afc3ee9c70ff).
Connecté en tant que OG VERITE | BOT#2244
D:\ya tout\bot\DiscordBot\bot.py
RuntimeWarning: coroutine 'BotBase.load_extension' was never awaited
bot.load_extension("commands.ping") # Charger l'extension ping directement ici
RuntimeWarning: Enable tracemalloc to get the object allocation traceback
Commande 'ping' chargée.
[2024-12-23 01:23:02] [ERROR ] discord.ext.commands.bot: Ignoring exception in command None
discord.ext.commands.errors.CommandNotFound: Command "ping" is not found
thank you bro
This help channel has been closed and it's no longer possible to send messages here. If your question wasn't answered, feel free to create a new post in #1035199133436354600. To maximize your chances of getting a response, check out this guide on asking good questions.