I previously had a Discord bot I wrote in Visual Studio Code and used several commands which worked great. However, when I try to use the Discord.py commands in Repl.it, they do nothing. I don’t get a traceback error or any feedback. The bot just won’t respond. Commands as simple as:
Can anyone suggest anything I might try? Like I said, I know the commands work with the discord.py API because I’ve run them with other programs.
Thanks,
-Drew
I am not familiar with discord or bots but I would say is that when Python does not do anything is when no function is being called OR you need to wrap the function in a print() statement to see output.
I had a look at the bot’s code. I think the issue here is the on_message listener.
Generally on any message sent, this first event triggered, and thus this over-rides the commands-processing.
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if msg.startswith('$inspire'):
quote = get_quote()
await message.channel.send(quote)
This can be resolved by either of the following methods-
@client.event
async def on_message(message):
if message.author == client.user:
return
msg = message.content
if msg.startswith('$inspire'):
quote = get_quote()
await message.channel.send(quote)
# process commands
await client.process_commands(message)
and Yaay, that should fix it
OR
Split the bot up into cogs and put the listener in it’s own cogs. If you are unfamiliar with the use of cogs, I suggest that you keep this method in mind for future, and use this later.
I have almost the same code as OP and whenever I try to use “await client.process_commands(message)” I get the error: “AttributeError: ‘NoneType’ object has no attribute ‘id’”