support #316

Merged
edraft merged 16 commits from support into master 2023-04-18 22:23:59 +02:00
4 changed files with 73 additions and 1 deletions
Showing only changes of commit 2befa921ea - Show all commits

View File

@ -25,10 +25,10 @@ class ModuleList:
DataModule,
GraphQLModule,
PermissionModule,
LevelModule,
DatabaseModule,
AutoRoleModule,
BaseModule,
LevelModule,
ApiModule,
TechnicianModule,
# has to be last!

View File

@ -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)

View File

@ -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)

View File

@ -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)