From b86ef8ac9bb7aeb5c7bd88931c53abe288b665a3 Mon Sep 17 00:00:00 2001 From: sgoudham Date: Tue, 23 Jun 2020 17:26:37 +0100 Subject: [PATCH] Fixed ~dm command by making sure the bot doesn't reply to itself --- EnsoBot.py | 6 ++++-- cogs/FunCommands.py | 12 +++++------- 2 files changed, 9 insertions(+), 9 deletions(-) diff --git a/EnsoBot.py b/EnsoBot.py index 2a5861b6..30db86fb 100644 --- a/EnsoBot.py +++ b/EnsoBot.py @@ -245,9 +245,11 @@ async def marry(ctx, member: discord.Member): await ctx.send("Awww they waited too long (✖╭╮✖)") -"""# Allows the bot to echo the dm's that it receives +# Allows the bot to echo the dm's that it receives @client.event async def on_message(message): + if message.author == client.user: + return # Checking if the message is not sent in server if message.guild is None: # Checking if the owner is sending the message @@ -260,7 +262,7 @@ async def on_message(message): channel = client.get_channel(721449922838134876) await channel.send(message.content) - await client.process_commands(message)""" + await client.process_commands(message) # Bot Event for handling all errors within discord.commands diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index 859e69a4..ebe8fa6f 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -176,17 +176,15 @@ class Fun(commands.Cog): # Send out one of the responses stored in the array await ctx.send(f"{ctx.author.mention} {random.choice(responses)}") - """ # ~dm only allows me to dm anyone through the bot @commands.command() @commands.is_owner() async def dm(self, ctx, member: discord.Member, *, text): - # Send the message typed the mentioned user - await member.send(text) - - # Delete the message sent instantly - await ctx.message.delete() - """ + # Send the message typed the mentioned user + await member.send(text) + + # Delete the message sent instantly + await ctx.message.delete() # ~remindme command to allow the bot to dm you to remind you of something @commands.command(aliases=["remindme", "rm"])