Added short role name check command
Some checks reported warnings
Deploy dev on push / on-push-deploy_sh-edraft (push) Has been cancelled
Some checks reported warnings
Deploy dev on push / on-push-deploy_sh-edraft (push) Has been cancelled
This commit is contained in:
parent
7acd850e68
commit
608001e0e1
@ -21,7 +21,6 @@
|
||||
}
|
||||
},
|
||||
"common": {
|
||||
"feature_not_activated": "Diese Funktion ist deaktiviert",
|
||||
"bot_has_no_permission_message": "Ey!!!\nWas soll das?\nIch habe keine Berechtigungen :(\nScheiß System...",
|
||||
"colors": {
|
||||
"blue": "Blau",
|
||||
@ -83,6 +82,7 @@
|
||||
"unexpected_quote_error": "Fehler: Unerwarteter Fehler beim Anführungszeichen!",
|
||||
"user_input_error": "Fehler: Eingabefehler!"
|
||||
},
|
||||
"feature_not_activated": "Diese Funktion ist deaktiviert",
|
||||
"hello_world": "Hallo Welt",
|
||||
"no_permission_message": "Nein!\nIch höre nicht auf dich ¯\\_(ツ)_/¯",
|
||||
"not_implemented_yet": "Ey Alter, das kann ich noch nicht...",
|
||||
@ -95,10 +95,10 @@
|
||||
},
|
||||
"modules": {
|
||||
"achievements": {
|
||||
"got_new_achievement": "{} hat die Errungenschaft {} freigeschaltet :D",
|
||||
"commands": {
|
||||
"check": "Alles klar, ich schaue eben nach... nom nom"
|
||||
}
|
||||
},
|
||||
"got_new_achievement": "{} hat die Errungenschaft {} freigeschaltet :D"
|
||||
},
|
||||
"auto_role": {
|
||||
"add": {
|
||||
@ -152,38 +152,37 @@
|
||||
}
|
||||
},
|
||||
"base": {
|
||||
"member_left_message": "{} hat uns leider verlassen :(",
|
||||
"complaints": {
|
||||
"title": "Beschwerde einreichen",
|
||||
"label": "Beschwerde",
|
||||
"message": "{} hat eine Beschwerde eingereicht:\n{}",
|
||||
"response": "Danke für deine Beschwerde"
|
||||
},
|
||||
"bug": {
|
||||
"title": "Bug melden",
|
||||
"label": "Bug",
|
||||
"message": "{} meldet einen Bug:\n{}",
|
||||
"response": "Danke für dein Feedback :D"
|
||||
},
|
||||
"afk_command_channel_missing_message": "Zu unfähig einem Sprachkanal beizutreten?",
|
||||
"afk_command_move_message": "Ich verschiebe dich ja schon... (◔_◔)",
|
||||
"bug": {
|
||||
"label": "Bug",
|
||||
"message": "{} meldet einen Bug:\n{}",
|
||||
"response": "Danke für dein Feedback :D",
|
||||
"title": "Bug melden"
|
||||
},
|
||||
"complaints": {
|
||||
"label": "Beschwerde",
|
||||
"message": "{} hat eine Beschwerde eingereicht:\n{}",
|
||||
"response": "Danke für deine Beschwerde",
|
||||
"title": "Beschwerde einreichen"
|
||||
},
|
||||
"game_server": {
|
||||
"add": {
|
||||
"success": "Gameserver {} wurde hinzugefügt :)"
|
||||
},
|
||||
"error": {
|
||||
"nothing_found": "Keine Gameserver gefunden."
|
||||
},
|
||||
"list_members": {
|
||||
"title": "Mitglieder",
|
||||
"description": "Konfigurierte Mitglieder:",
|
||||
"users": "Mitglieder"
|
||||
},
|
||||
"list": {
|
||||
"title": "Gameserver",
|
||||
"api_key": "API Key",
|
||||
"description": "Konfigurierte Gameserver:",
|
||||
"name": "Name",
|
||||
"api_key": "API Key"
|
||||
"title": "Gameserver"
|
||||
},
|
||||
"add": {
|
||||
"success": "Gameserver {} wurde hinzugefügt :)"
|
||||
"list_members": {
|
||||
"description": "Konfigurierte Mitglieder:",
|
||||
"title": "Mitglieder",
|
||||
"users": "Mitglieder"
|
||||
},
|
||||
"remove": {
|
||||
"success": "Gameserver wurde entfernt :D"
|
||||
@ -210,6 +209,7 @@
|
||||
"moved": "Alle Personen aus {} wurden nach {} verschoben."
|
||||
},
|
||||
"member_joined_help_voice_channel": "{} braucht Hilfe, bitte kümmere dich drum :D",
|
||||
"member_left_message": "{} hat uns leider verlassen :(",
|
||||
"pong": "Pong",
|
||||
"presence": {
|
||||
"changed": "Presence wurde geändert.",
|
||||
@ -346,6 +346,9 @@
|
||||
"moderator": {
|
||||
"purge_message": "Na gut..., ich lösche alle Nachrichten wenns sein muss."
|
||||
},
|
||||
"short_role_name": {
|
||||
"checked_message": "Die Rollen Kürzel wurden überprüft"
|
||||
},
|
||||
"technician": {
|
||||
"api_key": {
|
||||
"add": {
|
||||
@ -357,10 +360,10 @@
|
||||
"success": "API-Schlüssel wurde entfernt :D"
|
||||
}
|
||||
},
|
||||
"synced_message": "Der Sync wurde abgeschlossen.",
|
||||
"log_message": "Hier sind deine Logdateien! :)",
|
||||
"restart_message": "Bin gleich wieder da :D",
|
||||
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, euer Freund. Lebt lange und in Frieden :)"
|
||||
"shutdown_message": "Trauert nicht um mich, es war eine logische Entscheidung. Das Wohl von Vielen, es wiegt schwerer als das Wohl von Wenigen oder eines Einzelnen. Ich war es und ich werde es immer sein, euer Freund. Lebt lange und in Frieden :)",
|
||||
"synced_message": "Der Sync wurde abgeschlossen."
|
||||
}
|
||||
}
|
||||
}
|
@ -228,7 +228,7 @@ class ClientUtilsService(ClientUtilsABC):
|
||||
return
|
||||
|
||||
default_role = member.guild.get_role(settings.default_role_id)
|
||||
if default_role in member.roles:
|
||||
if default_role is None or default_role in member.roles:
|
||||
return
|
||||
|
||||
await member.add_roles(default_role)
|
||||
|
@ -0,0 +1,60 @@
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_discord.command import DiscordCommandABC
|
||||
from cpl_translation import TranslatePipe
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_core.configuration.feature_flags_settings import FeatureFlagsSettings
|
||||
from bot_core.helper.command_checks import CommandChecks
|
||||
from bot_core.logging.command_logger import CommandLogger
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
from modules.permission.abc.permission_service_abc import PermissionServiceABC
|
||||
from modules.short_role_name.service.short_role_name_service import ShortRoleNameService
|
||||
|
||||
|
||||
class ShortRoleNameCheckCommand(DiscordCommandABC):
|
||||
def __init__(
|
||||
self,
|
||||
logger: CommandLogger,
|
||||
config: ConfigurationABC,
|
||||
message_service: MessageServiceABC,
|
||||
permissions: PermissionServiceABC,
|
||||
client_utils: ClientUtilsABC,
|
||||
translate: TranslatePipe,
|
||||
short_role_name_service: ShortRoleNameService,
|
||||
):
|
||||
DiscordCommandABC.__init__(self)
|
||||
|
||||
self._logger = logger
|
||||
self._config = config
|
||||
self._message_service = message_service
|
||||
self._permissions = permissions
|
||||
self._client_utils = client_utils
|
||||
self._t = translate
|
||||
self._service = short_role_name_service
|
||||
|
||||
self._logger.trace(__name__, f"Loaded command service: {type(self).__name__}")
|
||||
|
||||
@commands.hybrid_command(name="short-role-name-check")
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_moderator()
|
||||
async def short_role_name_check(self, ctx: Context):
|
||||
self._logger.debug(__name__, f"Received command purge {ctx}")
|
||||
if ctx.guild is None:
|
||||
return
|
||||
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||
if not FeatureFlagsSettings.get_flag_from_dict(settings.feature_flags, FeatureFlagsEnum.game_server):
|
||||
await self._message_service.send_ctx_msg(ctx, self._t.transform("common.feature_not_activated"))
|
||||
return
|
||||
|
||||
for member in ctx.guild.members:
|
||||
await self._service.check_short_role_names(member)
|
||||
|
||||
await self._message_service.send_ctx_msg(ctx, self._t.transform("modules.short_role_name.checked_message"))
|
||||
|
||||
self._logger.trace(__name__, f"Finished purge command")
|
@ -9,6 +9,7 @@ from bot_core.configuration.feature_flags_enum import FeatureFlagsEnum
|
||||
from bot_data.abc.data_seeder_abc import DataSeederABC
|
||||
from modules.short_role_name.events.short_role_name_on_member_update_event import ShortRoleNameOnMemberUpdateEvent
|
||||
from modules.short_role_name.service.short_role_name_service import ShortRoleNameService
|
||||
from modules.short_role_name.short_role_name_check_command import ShortRoleNameCheckCommand
|
||||
from modules.short_role_name.short_role_name_seeder import ShortRoleNameSeeder
|
||||
|
||||
|
||||
@ -24,5 +25,6 @@ class ShortRoleNameModule(ModuleABC):
|
||||
services.add_transient(ShortRoleNameService)
|
||||
|
||||
# commands
|
||||
self._dc.add_command(ShortRoleNameCheckCommand)
|
||||
# events
|
||||
self._dc.add_event(DiscordEventTypesEnum.on_member_update.value, ShortRoleNameOnMemberUpdateEvent)
|
||||
|
Loading…
Reference in New Issue
Block a user