forked from sh-edraft.de/sh_discord_bot
Added logic to send mods a message when member joins help channel #113
This commit is contained in:
parent
905182931c
commit
49d9509255
@ -1 +1 @@
|
|||||||
Subproject commit 6f63688fd914ad6fb3fc5249e4b3763dc261997a
|
Subproject commit bd8d3a5dad13e0fdcad79b767c032997b716b1a4
|
@ -139,6 +139,7 @@
|
|||||||
"goodbye_message": "Schade das du uns so schnell verlässt :(",
|
"goodbye_message": "Schade das du uns so schnell verlässt :(",
|
||||||
"afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?",
|
"afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?",
|
||||||
"afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)",
|
"afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)",
|
||||||
|
"member_joined_help_voice_channel": "{} braucht hilfe, bitte kümmer dich drum :D",
|
||||||
"pong": "Pong",
|
"pong": "Pong",
|
||||||
"info": {
|
"info": {
|
||||||
"title": "Gismo",
|
"title": "Gismo",
|
||||||
|
@ -21,6 +21,7 @@ from modules.base.events.base_on_member_join_event import BaseOnMemberJoinEvent
|
|||||||
from modules.base.events.base_on_member_remove_event import BaseOnMemberRemoveEvent
|
from modules.base.events.base_on_member_remove_event import BaseOnMemberRemoveEvent
|
||||||
from modules.base.events.base_on_message_event import BaseOnMessageEvent
|
from modules.base.events.base_on_message_event import BaseOnMessageEvent
|
||||||
from modules.base.events.base_on_voice_state_update_event import BaseOnVoiceStateUpdateEvent
|
from modules.base.events.base_on_voice_state_update_event import BaseOnVoiceStateUpdateEvent
|
||||||
|
from modules.base.events.base_on_voice_state_update_event_help_channel import BaseOnVoiceStateUpdateEventHelpChannel
|
||||||
from modules.base.service.base_helper_service import BaseHelperService
|
from modules.base.service.base_helper_service import BaseHelperService
|
||||||
|
|
||||||
|
|
||||||
@ -51,3 +52,4 @@ class BaseModule(ModuleABC):
|
|||||||
self._dc.add_event(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent)
|
self._dc.add_event(DiscordEventTypesEnum.on_member_remove.value, BaseOnMemberRemoveEvent)
|
||||||
self._dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent)
|
self._dc.add_event(DiscordEventTypesEnum.on_message.value, BaseOnMessageEvent)
|
||||||
self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent)
|
self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEvent)
|
||||||
|
self._dc.add_event(DiscordEventTypesEnum.on_voice_state_update.value, BaseOnVoiceStateUpdateEventHelpChannel)
|
||||||
|
@ -17,6 +17,7 @@ class BaseServerSettings(ConfigurationModelABC):
|
|||||||
self._afk_channel_ids: List[int] = List(int)
|
self._afk_channel_ids: List[int] = List(int)
|
||||||
self._afk_command_channel_id: int = 0
|
self._afk_command_channel_id: int = 0
|
||||||
self._help_command_reference_url: str = ''
|
self._help_command_reference_url: str = ''
|
||||||
|
self._help_voice_channel_id: int = 0
|
||||||
|
|
||||||
@property
|
@property
|
||||||
def id(self) -> int:
|
def id(self) -> int:
|
||||||
@ -46,6 +47,10 @@ class BaseServerSettings(ConfigurationModelABC):
|
|||||||
def help_command_reference_url(self) -> str:
|
def help_command_reference_url(self) -> str:
|
||||||
return self._help_command_reference_url
|
return self._help_command_reference_url
|
||||||
|
|
||||||
|
@property
|
||||||
|
def help_voice_channel_id(self) -> int:
|
||||||
|
return self._help_voice_channel_id
|
||||||
|
|
||||||
def from_dict(self, settings: dict):
|
def from_dict(self, settings: dict):
|
||||||
try:
|
try:
|
||||||
self._id = int(settings['Id'])
|
self._id = int(settings['Id'])
|
||||||
@ -56,6 +61,7 @@ class BaseServerSettings(ConfigurationModelABC):
|
|||||||
self._afk_channel_ids.append(int(index))
|
self._afk_channel_ids.append(int(index))
|
||||||
self._afk_command_channel_id = settings['AFKCommandChannelId']
|
self._afk_command_channel_id = settings['AFKCommandChannelId']
|
||||||
self._help_command_reference_url = settings['HelpCommandReferenceUrl']
|
self._help_command_reference_url = settings['HelpCommandReferenceUrl']
|
||||||
|
self._help_voice_channel_id = settings['HelpVoiceChannelId']
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
Console.error(f'[ ERROR ] [ {__name__} ]: Reading error in {type(self).__name__} settings')
|
||||||
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
Console.error(f'[ EXCEPTION ] [ {__name__} ]: {e} -> {traceback.format_exc()}')
|
||||||
|
@ -0,0 +1,53 @@
|
|||||||
|
import discord
|
||||||
|
from cpl_core.configuration import ConfigurationABC
|
||||||
|
from cpl_core.logging import LoggerABC
|
||||||
|
from cpl_discord.events import OnVoiceStateUpdateABC
|
||||||
|
from cpl_translation import TranslatePipe
|
||||||
|
|
||||||
|
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||||
|
from bot_core.helper.event_checks import EventChecks
|
||||||
|
from bot_data.abc.server_repository_abc import ServerRepositoryABC
|
||||||
|
from modules.base.abc.base_helper_abc import BaseHelperABC
|
||||||
|
from modules.base.configuration.base_server_settings import BaseServerSettings
|
||||||
|
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||||
|
|
||||||
|
|
||||||
|
class BaseOnVoiceStateUpdateEventHelpChannel(OnVoiceStateUpdateABC):
|
||||||
|
|
||||||
|
def __init__(
|
||||||
|
self,
|
||||||
|
config: ConfigurationABC,
|
||||||
|
logger: LoggerABC,
|
||||||
|
base_helper: BaseHelperABC,
|
||||||
|
servers: ServerRepositoryABC,
|
||||||
|
permissions: PermissionServiceABC,
|
||||||
|
message_service: MessageServiceABC,
|
||||||
|
t: TranslatePipe,
|
||||||
|
):
|
||||||
|
OnVoiceStateUpdateABC.__init__(self)
|
||||||
|
self._config = config
|
||||||
|
self._logger = logger
|
||||||
|
self._base_helper = base_helper
|
||||||
|
self._servers = servers
|
||||||
|
self._permissions = permissions
|
||||||
|
self._message_service = message_service
|
||||||
|
self._t = t
|
||||||
|
|
||||||
|
self._logger.info(__name__, f'Module {type(self)} loaded')
|
||||||
|
|
||||||
|
@EventChecks.check_is_ready()
|
||||||
|
async def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
|
||||||
|
self._logger.debug(__name__, f'Module {type(self)} started')
|
||||||
|
server = self._servers.get_server_by_discord_id(member.guild.id)
|
||||||
|
settings: BaseServerSettings = self._base_helper.get_config(server.discord_server_id)
|
||||||
|
if after.channel is None or after.channel.id != settings.help_voice_channel_id:
|
||||||
|
return
|
||||||
|
|
||||||
|
mods = [*self._permissions.get_admins(member.guild.id), *self._permissions.get_moderators(member.guild.id)]
|
||||||
|
for a in mods:
|
||||||
|
await self._message_service.send_dm_message(
|
||||||
|
self._t.transform('modules.base.member_joined_help_voice_channel').format(member.name),
|
||||||
|
a,
|
||||||
|
)
|
||||||
|
|
||||||
|
self._logger.debug(__name__, f'Module {type(self)} stopped')
|
Loading…
Reference in New Issue
Block a user