Improved auto-role-rule list #54

This commit is contained in:
2022-10-03 22:22:51 +02:00
parent b35b023b02
commit 21c34436b9
3 changed files with 42 additions and 7 deletions

View File

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

View File

@@ -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]]: