I'm doing a modmail and I've run into a big problem below I leave the code
import discord
from discord.ext import commands
#PREFIJOS E INTENTS
intents = discord.Intents.default()
intents.guild_reactions = True
intents.guild_messages = True
intents.messages = True
client = commands.Bot(command_prefix="x-",intents=intents)
@client.event
async def on_ready():
print("Listo")
await client.change_presence(activity=discord.Activity(type=discord.ActivityType.playing, name="Dev = PingüiMaya14")) #CONFIGURA EL TEXTO DE LA ACTIVIDAD QUE ESTÁ HACIENDO
@client.command(pass_context = True)
async def react(ctx ):
msg = await ctx.send("Hola")
await msg.add_reaction("✅")
@client.command(pass_context=True)
@commands.has_role("ADMIN")
async def setup(ctx):
guild = ctx.message.guild
await guild.create_text_channel("mod-mail")
msg = await ctx.send("Canal Creado - Configura los roles que tenga acceso en la configuración del chat")
await msg.add_reaction("✅")
#modmail
@client.event
async def on_message(message):
empty_array = []
modmail_channel = discord.utils.get(client.get_all_channels(), name="mod-mail")
if message.author == client.user:
return
if str(message.channel.type) == "private":
if message.attachments != empty_array:
files = message.attachments
await modmail_channel.send("[" + message.author.display_name + "]")
for file in files:
await modmail_channel.send(file.url)
else:
await modmail_channel.send("[" + message.author.display_name + "] " + message.content)
elif str(message.channel) == "mod-mail" and message.content.startswith("<"):
member_object = message.mentions[0]
if message.attachments != empty_array:
files = message.attachments
await member_object.send("[" + message.author.display_name + "]")
for file in files:
await member_object.send(file.url)
else:
index = message.content.index(" ")
string = message.content
mod_message = string[index:]
await member_object.send("[" + message.author.display_name + "]" + mod_message)
client.run("TOKEN")
The modmail works and everything, the problem is the following: "The other commands do not work"
For example there are two commands setup and react
When I use x-react the bot ignores and does nothing and there I should write hello and react
(I have tried the same code without modmail and the commands work for me so I think the error is in the modmail part)
To fix it, add
At the end of on_message