Added logic to log reactions #169
This commit is contained in:
parent
4c577f6a7b
commit
d10c33c6c2
@ -3,6 +3,7 @@ from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.log_message_helper import LogMessageHelper
|
||||
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||
from bot_data.abc.user_repository_abc import UserRepositoryABC
|
||||
from modules.base.abc.base_helper_abc import BaseHelperABC
|
||||
@ -36,6 +37,20 @@ class BaseReactionHandler:
|
||||
self._logger.warn(__name__, f'User {payload.user_id} in {guild.name} not found - skipping')
|
||||
return
|
||||
|
||||
try:
|
||||
log_msg = f'{member.name} reacted'
|
||||
if payload.emoji.name is not None:
|
||||
log_msg += f' with {payload.emoji.name}'
|
||||
try:
|
||||
channel = guild.get_channel(payload.channel_id)
|
||||
message = await channel.fetch_message(payload.message_id)
|
||||
self._logger.info(__name__, f'{log_msg} to message {LogMessageHelper.get_log_string(message)}')
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f'Getting message for reaction logging failed', e)
|
||||
self._logger.info(__name__, f'{log_msg} to message {payload.message_id}')
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f'Reaction logging failed', e)
|
||||
|
||||
if member.bot:
|
||||
return
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user