Also react to message deletion, move shared event logic into method
This commit is contained in:
parent
37ac796c62
commit
fab1483f18
22
ahtcg_bot.py
22
ahtcg_bot.py
|
@ -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:
|
||||
|
|
Loading…
Reference in New Issue