From 3e86b8d519039c4751964aef5cc5df99b0e06da1 Mon Sep 17 00:00:00 2001 From: Ave Ozkal Date: Mon, 24 Dec 2018 11:26:19 +0300 Subject: [PATCH] mod: Hedge-proof the code --- cogs/mod.py | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+) diff --git a/cogs/mod.py b/cogs/mod.py index 19a5e9a..d2e86f5 100644 --- a/cogs/mod.py +++ b/cogs/mod.py @@ -47,6 +47,9 @@ class ModCog: if self.check_if_target_is_staff(target): return await ctx.send("I can't mute this user as " "they're a member of staff.") + # Hedge-proofing the code + elif target == ctx.author: + return await ctx.send("You can't do mod actions on yourself.") safe_name = self.bot.escape_message(str(target)) @@ -113,6 +116,9 @@ class ModCog: if self.check_if_target_is_staff(target): return await ctx.send("I can't kick this user as " "they're a member of staff.") + # Hedge-proofing the code + elif target == ctx.author: + return await ctx.send("You can't do mod actions on yourself.") safe_name = self.bot.escape_message(str(target)) @@ -152,6 +158,9 @@ class ModCog: if self.check_if_target_is_staff(target): return await ctx.send("I can't ban this user as " "they're a member of staff.") + # Hedge-proofing the code + elif target == ctx.author: + return await ctx.send("You can't do mod actions on yourself.") safe_name = self.bot.escape_message(str(target)) @@ -189,6 +198,9 @@ class ModCog: if self.check_if_target_is_staff(target): return await ctx.send("I can't ban this user as " "they're a member of staff.") + # Hedge-proofing the code + elif target == ctx.author.id: + return await ctx.send("You can't do mod actions on yourself.") safe_name = self.bot.escape_message(str(target)) @@ -217,6 +229,9 @@ class ModCog: if self.check_if_target_is_staff(target): return await ctx.send("I can't ban this user as " "they're a member of staff.") + # Hedge-proofing the code + elif target == ctx.author: + return await ctx.send("You can't do mod actions on yourself.") safe_name = self.bot.escape_message(str(target)) @@ -365,6 +380,9 @@ class ModCog: if self.check_if_target_is_staff(target): return await ctx.send("I can't warn this user as " "they're a member of staff.") + # Hedge-proofing the code + elif target == ctx.author: + return await ctx.send("You can't do mod actions on yourself.") log_channel = self.bot.get_channel(config.log_channel) with open("data/warnsv2.json", "r") as f: