Also react to message deletion, move shared event logic into method

This commit is contained in:
Adam Goldsmith 2021-05-03 01:14:19 -04:00
parent 37ac796c62
commit fab1483f18
1 changed files with 10 additions and 12 deletions

View File

@ -103,23 +103,21 @@ class ArkhamDBUpdater(commands.Bot):
else:
await channel.send(embed=message_embed)
async def maybe_update_channel_for_message(self, message: discord.Message) -> None:
# don't to react to the bot's changes, and only update registered channels
if message.author.id != self.user.id and \
message.channel.id in self.channel_list:
await self.update_channel_latest_decks(message)
async def on_message(self, message: discord.Message):
await self.process_commands(message)
# we do not want the bot to reply to itself
if message.author.id == self.user.id:
return
if message.channel.id in self.channel_list:
await self.update_channel_latest_decks(message.channel)
await self.maybe_update_channel_for_message(message)
async def on_message_edit(self, before: discord.Message, after: discord.Message):
# we do not want the bot to reply to itself
if after.author.id == self.user.id:
return
await self.maybe_update_channel_for_message(after)
if after.channel.id in self.channel_list:
await self.update_channel_latest_decks(after.channel)
async def on_message_delete(self, message: discord.Message):
await self.maybe_update_channel_for_message(message)
@tasks.loop(hours=1)
async def arkhamdb_monitor(self) -> None: