diff --git a/src/bot/translation/de.json b/src/bot/translation/de.json index d009e38e79..db98a9a73a 100644 --- a/src/bot/translation/de.json +++ b/src/bot/translation/de.json @@ -55,10 +55,25 @@ }, "auto_role": { "list": { - "title": "beobachtete Nachrichten:", + "title": "Beobachtete Nachrichten:", "description": "Von auto-role beobachtete Nachrichten:", "auto_role_id": "auto-role Id", "message_id": "Nachricht-Id" + }, + "rule": { + "list": { + "title": "auto-role Regeln:", + "description": "Von auto-role angewendete Regeln:", + "auto_role_id": "auto-role Id", + "emoji": "Emoji", + "role": "Rolle" + }, + "error": { + "id_not_found": "Kein auto-role Eintrag mit der Id gefunden!" + } + }, + "error": { + "nothing_found": "Keine auto-role Einträge gefunden." } }, "moderator": { diff --git a/src/modules/autorole/command/auto_role_command.py b/src/modules/autorole/command/auto_role_command.py index 0960c6eb66..733d413ffa 100644 --- a/src/modules/autorole/command/auto_role_command.py +++ b/src/modules/autorole/command/auto_role_command.py @@ -54,14 +54,18 @@ class AutoRoleCommand(DiscordCommandABC): description=self._t.transform('modules.auto_role.list.description'), color=int('ef9d0d', 16) ) + auto_roles = self._auto_roles.get_auto_roles() + if auto_roles.count() < 1: + await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.error.nothing_found')) + self._logger.trace(__name__, f'Finished command auto-role list') + return auto_role_id = '' - for id in self._auto_roles.get_auto_roles().select(lambda x: x.auto_role_id): - auto_role_id += f'\n{id}' - message_id = '' - for id in self._auto_roles.get_auto_roles().select(lambda x: x.discord_message_id): - message_id += f'\n{id}' + for auto_role in auto_roles: + auto_role_id += f'\n{auto_role.auto_role_id}' + message_id += f'\n{auto_role.discord_message_id}' + embed.add_field(name=self._t.transform('modules.auto_role.list.auto_role_id'), value=auto_role_id, inline=True) embed.add_field(name=self._t.transform('modules.auto_role.list.message_id'), value=message_id, inline=True) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) diff --git a/src/modules/autorole/command/auto_role_rule_command.py b/src/modules/autorole/command/auto_role_rule_command.py index 3e2ab240ae..3027acaffe 100644 --- a/src/modules/autorole/command/auto_role_rule_command.py +++ b/src/modules/autorole/command/auto_role_rule_command.py @@ -57,9 +57,25 @@ class AutoRoleRuleCommand(DiscordCommandABC): description=self._t.transform('modules.auto_role.list.description'), color=int('ef9d0d', 16) ) + rules = self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role) + if rules.count() < 1: + await self._message_service.send_ctx_msg(ctx, self._t.transform('modules.auto_role.rule.error.id_not_found')) + self._logger.trace(__name__, f'Finished command auto-role-rule list') + return + auto_role_rule_id = '' + emoji = '' + role = '' + for rule in rules: + auto_role_rule_id += f'\n{rule.role_id}' + emoji += f'\n{rule.emoji_name}' + role += f'\n{ctx.guild.get_role(rule.role_id)}' + + embed.add_field(name=self._t.transform('modules.auto_role.rule.list.auto_role_id'), value=auto_role_rule_id, inline=True) + embed.add_field(name=self._t.transform('modules.auto_role.rule.list.emoji'), value=emoji, inline=True) + embed.add_field(name=self._t.transform('modules.auto_role.rule.list.role'), value=role, inline=True) await self._message_service.send_ctx_msg(ctx, embed, wait_before_delete=wait) - self._logger.trace(__name__, f'Finished command auto-role list') + self._logger.trace(__name__, f'Finished command auto-role-rule list') @list.autocomplete('auto_role') async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> List[app_commands.Choice[str]]: