#๐ discord bot i need help with this
33 messages ยท Page 1 of 1 (latest)
@lean musk
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.
what?
is this a command or an on_message event?
command
also im pretty sure you can solve this with a simple get request
i just started doing python not long
there arent any commands in the code sample you showed me
my friend helped me alot so i don't very know my bad but like
does it anywhere say what the command is?
# event
@bot.event
async def on_message(message):
...
# command
@bot.command()
async def my_command(ctx):
...```
Registering the on_message event with @bot.event will override the default behavior of the event. This may cause prefix commands to stop working, because they rely on the default on_message event handler.
Instead, use @bot.listen to add a listener. Listeners get added alongside the default on_message handler which allows you to have multiple handlers for the same event. This means prefix commands can still be invoked as usual. Here's an example:
@bot.listen()
async def on_message(message):
... # do stuff here
# Or...
@bot.listen('on_message')
async def message_listener(message):
... # do stuff here
You can also tell discord.py to process the message for commands as usual at the end of the on_message handler with bot.process_commands(). However, this method isn't recommended as it does not allow you to add multiple on_message handlers.
If your prefix commands are still not working, it may be because you haven't enabled the message_content intent. See /tag message_content for more info.
it sends the information ?
nope
they're two fundamentally different things
an event listener just listens for when an event takes place
this could be a message, a profile change, a status change, etc
a command is exclusively run
and also has a lot more functionality than with a message listener
i was literally trying to figure out what the command was bruh
for like 2 hours
lmao
You should check out #discord-bots and read the pinned messages.

ty
that code only runs when a message has "tiktok.com" in it
it doesnt even need a prefix
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.