aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daniel Brown <[email protected]>2018-09-06 17:30:14 -0500
committerGravatar Daniel Brown <[email protected]>2018-09-06 17:30:14 -0500
commitdbb58437192baff1641a7ada5b5863c60f5d3f5d (patch)
tree6a8dccb392135f4896e8c3fec269a29913080583
parentCompleted editing deletion. Still working on reaction deletion. (diff)
Added Python format embed removal, either by the user correcting their formatting or by clicking the reaction, which can be done by the user who caused it or by staff.
-rw-r--r--bot/cogs/bot.py18
1 files changed, 17 insertions, 1 deletions
diff --git a/bot/cogs/bot.py b/bot/cogs/bot.py
index fd49733eb..001e2e2fe 100644
--- a/bot/cogs/bot.py
+++ b/bot/cogs/bot.py
@@ -343,6 +343,7 @@ class Bot:
howto_embed = Embed(description=howto)
bot_msg = await msg.channel.send(f"Hey {msg.author.mention}!", embed=howto_embed)
self.py_msg_ids[msg.id] = bot_msg.id
+ await bot_msg.add_reaction("❌")
else:
return
@@ -362,9 +363,24 @@ class Bot:
await bot_msg.delete()
async def on_reaction_add(self, reaction, user):
- if user.id == self.id:
+ if user.id == self.id or reaction.message.id not in self.py_msg_ids.values():
return
+ for k, v in self.py_msg_ids.items():
+ if v == reaction.message.id:
+ msg = await reaction.message.channel.get_message(k)
+ bot_msg = await reaction.message.channel.get_message(v)
+ break
+
+ if user == msg.author:
+ await bot_msg.delete()
+ return
+
+ for role in user.roles:
+ if role.id in (Roles.owner, Roles.admin, Roles.moderator):
+ await bot_msg.delete()
+ return
+
def setup(bot):
bot.add_cog(Bot(bot))