From e2269d4c7ad008608e967bf1b3a79bdb4e4a6ea6 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Thu, 2 Jul 2020 17:43:00 +0100 Subject: [PATCH] Adding on_message event make sure that commands are processed --- main.py | 45 +++++++++------------------------------------ 1 file changed, 9 insertions(+), 36 deletions(-) diff --git a/main.py b/main.py index 0f6c421f..099c8fed 100644 --- a/main.py +++ b/main.py @@ -1,10 +1,9 @@ import asyncio import datetime -import random import discord from decouple import config -from discord import Embed, Colour, DMChannel +from discord import Embed, Colour from discord.ext import commands from discord.ext.commands import is_owner @@ -28,6 +27,14 @@ if __name__ == '__main__': client.load_extension(ext) +@client.event +async def on_message(message): + if message.author.bot: + return + + await client.process_commands(message) + + # Bot Status on Discord @client.event async def on_ready(): @@ -80,40 +87,6 @@ async def on_member_join(member): await new_people.send(embed=embed) -# Allows the bot to echo the dm's that it receives -@client.event -async def on_message(message): - # Making sure that the bot doesn't reply to itself - if message.author == client.user: - return - - # Get the mod-mail channel - channel = client.get_channel(728083016290926623) - - if isinstance(message.channel, DMChannel): - if len(message.content) < 50: - await message.channel.send("Your message should be at least 50 characters in length.") - - else: - # member = discord.guild.get_member(message.author.id) - embed = Embed(title="**Modmail**", - colour=Colour(random.choice(settings.colour_list)), - timestamp=datetime.datetime.utcnow()) - - embed.set_thumbnail(url=message.author.avatar_url) - - fields = [("Member", message.author, False), - ("Message", message.content, False)] - - for name, value, inline in fields: - embed.add_field(name=name, value=value, inline=inline) - - await channel.send(embed=embed) - await message.channel.send("**Message relayed to Staff! Thank you for your input!**") - - await client.process_commands(message) - - # Bot Event for handling all errors within discord.commands @client.event async def on_command_error(ctx, args2):