Reviewed-on: sh-edraft.de/kd_discord_bot#305 Reviewed-by: Ebola-Chan <nick.jungmann@gmail.com> Closes #304
This commit is contained in:
commit
ebdf375283
@ -25,10 +25,10 @@ class ModuleList:
|
||||
DataModule,
|
||||
GraphQLModule,
|
||||
PermissionModule,
|
||||
LevelModule,
|
||||
DatabaseModule,
|
||||
AutoRoleModule,
|
||||
BaseModule,
|
||||
LevelModule,
|
||||
ApiModule,
|
||||
TechnicianModule,
|
||||
# has to be last!
|
||||
|
@ -0,0 +1,34 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events.on_raw_reaction_add_abc import OnRawReactionAddABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from modules.level.service.level_service import LevelService
|
||||
|
||||
|
||||
class LevelOnRawReactionAddEvent(OnRawReactionAddABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
bot: DiscordBotServiceABC,
|
||||
level: LevelService,
|
||||
):
|
||||
OnRawReactionAddABC.__init__(self)
|
||||
|
||||
self._logger = logger
|
||||
self._bot = bot
|
||||
self._level = level
|
||||
|
||||
@EventChecks.check_is_ready()
|
||||
async def on_raw_reaction_add(self, payload: RawReactionActionEvent):
|
||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||
try:
|
||||
self._logger.trace(__name__, f"Handle reaction {payload} for level")
|
||||
|
||||
guild = self._bot.get_guild(payload.guild_id)
|
||||
member = guild.get_member(payload.user_id)
|
||||
|
||||
await self._level.check_level(member)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Level check by message failed", e)
|
@ -0,0 +1,34 @@
|
||||
from cpl_core.logging import LoggerABC
|
||||
from cpl_discord.events.on_raw_reaction_remove_abc import OnRawReactionRemoveABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from discord import RawReactionActionEvent
|
||||
|
||||
from bot_core.helper.event_checks import EventChecks
|
||||
from modules.level.service.level_service import LevelService
|
||||
|
||||
|
||||
class LevelOnRawReactionRemoveEvent(OnRawReactionRemoveABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: LoggerABC,
|
||||
bot: DiscordBotServiceABC,
|
||||
level: LevelService,
|
||||
):
|
||||
OnRawReactionRemoveABC.__init__(self)
|
||||
|
||||
self._logger = logger
|
||||
self._bot = bot
|
||||
self._level = level
|
||||
|
||||
@EventChecks.check_is_ready()
|
||||
async def on_raw_reaction_remove(self, payload: RawReactionActionEvent):
|
||||
self._logger.debug(__name__, f"Module {type(self)} started")
|
||||
try:
|
||||
self._logger.trace(__name__, f"Handle reaction {payload} for level")
|
||||
|
||||
guild = self._bot.get_guild(payload.guild_id)
|
||||
member = guild.get_member(payload.user_id)
|
||||
|
||||
await self._level.check_level(member)
|
||||
except Exception as e:
|
||||
self._logger.error(__name__, f"Level check by message failed", e)
|
@ -12,6 +12,8 @@ from bot_data.abc.data_seeder_abc import DataSeederABC
|
||||
from modules.level.command.level_group import LevelGroup
|
||||
from modules.level.events.level_on_member_join_event import LevelOnMemberJoinEvent
|
||||
from modules.level.events.level_on_message_event import LevelOnMessageEvent
|
||||
from modules.level.events.level_on_raw_reaction_add_event import LevelOnRawReactionAddEvent
|
||||
from modules.level.events.level_on_raw_reaction_remove_event import LevelOnRawReactionRemoveEvent
|
||||
from modules.level.events.level_on_voice_state_update_event import (
|
||||
LevelOnVoiceStateUpdateEvent,
|
||||
)
|
||||
@ -43,3 +45,5 @@ class LevelModule(ModuleABC):
|
||||
LevelOnVoiceStateUpdateEvent,
|
||||
)
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_member_join.value, LevelOnMemberJoinEvent)
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_add.value, LevelOnRawReactionAddEvent)
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_raw_reaction_remove.value, LevelOnRawReactionRemoveEvent)
|
||||
|
Loading…
Reference in New Issue
Block a user