'Discord.py bot doesn't respond to commands but does on mentions
I have a problem with my discord.py bot. Here's a part of the code:
import os, discord
from discord.ext import commands
from flask import Flask
from threading import Thread
PREFIX = '/'
client = commands.Bot(command_prefix=PREFIX)
app = Flask('')
@app.route('/')
def main():
return 'Bot is ready!'
def run():
app.run(host="0.0.0.0", port=8000)
def keep_alive():
server = Thread(target=run)
server.start()
@client.event
async def on_message(message):
if client.user.mentioned_in(message):
await message.channel.send(embed=infoEmbed) #infoEmbed is defined
@client.command()
async def test(ctx, txt):
await ctx.send('You said ' + txt)
keep_alive()
client.run(os.environ['bot_token'])
I run the code, but it doesn't respond to commands, just on mentions. I cannot find the bug. Can you help me?
Solution 1:[1]
I think I know. You made the prefix “/“. Discord recently added a feature where bots could respond to / commands, but only if you add certain code I believe. Try using a new prefix? If that helps let me know.
Sources
This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.
Source: Stack Overflow
| Solution | Source |
|---|---|
| Solution 1 | CloovyYT |
