Merge branch '0.3' into #105
This commit is contained in:
commit
55c43efbdc
@ -22,7 +22,7 @@ class AutoRoleRepositoryABC(ABC):
|
||||
def find_auto_role_by_id(self, id: int) -> Optional[AutoRole]: pass
|
||||
|
||||
@abstractmethod
|
||||
def get_auto_roles_by_server_id(self, id: int) -> AutoRole: pass
|
||||
def get_auto_roles_by_server_id(self, id: int) -> List[AutoRole]: pass
|
||||
|
||||
@abstractmethod
|
||||
def get_auto_role_by_message_id(self, id: int) -> AutoRole: pass
|
||||
|
@ -67,12 +67,16 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
self._logger.trace(__name__, f'Finished command auto-role list')
|
||||
return
|
||||
|
||||
if ctx.guild is None:
|
||||
return
|
||||
|
||||
embed = discord.Embed(
|
||||
title=self._t.transform('modules.auto_role.list.title'),
|
||||
description=self._t.transform('modules.auto_role.list.description'),
|
||||
color=int('ef9d0d', 16)
|
||||
)
|
||||
auto_roles = self._auto_roles.get_auto_roles()
|
||||
server = self._servers.get_server_by_discord_id(ctx.guild.id)
|
||||
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.server_id)
|
||||
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')
|
||||
@ -168,7 +172,8 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
|
||||
@remove.autocomplete('auto_role')
|
||||
async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
||||
auto_roles = self._auto_roles.get_auto_roles().select(lambda x: x.auto_role_id)
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.server_id).select(lambda x: x.auto_role_id)
|
||||
return [app_commands.Choice(name=auto_role, value=auto_role) for auto_role in auto_roles]
|
||||
|
||||
@auto_role.group()
|
||||
@ -216,7 +221,8 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
|
||||
@list.autocomplete('auto_role')
|
||||
async def list_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
||||
auto_roles = self._auto_roles.get_auto_roles().select(lambda x: x.auto_role_id)
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.server_id).select(lambda x: x.auto_role_id)
|
||||
return [app_commands.Choice(name=auto_role, value=auto_role) for auto_role in auto_roles]
|
||||
|
||||
@rule.command()
|
||||
@ -264,7 +270,8 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
|
||||
@add.autocomplete('auto_role')
|
||||
async def add_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
||||
auto_roles = self._auto_roles.get_auto_roles().select(lambda x: x.auto_role_id)
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.server_id).select(lambda x: x.auto_role_id)
|
||||
return [app_commands.Choice(name=auto_role, value=auto_role) for auto_role in auto_roles]
|
||||
|
||||
@add.autocomplete('emoji_name')
|
||||
@ -305,6 +312,7 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
|
||||
@remove.autocomplete('auto_role_rule')
|
||||
async def remove_autocomplete(self, interaction: discord.Interaction, current: str) -> TList[app_commands.Choice[str]]:
|
||||
rules = self._auto_roles.get_auto_role_rules()
|
||||
return [app_commands.Choice(name=f'{rule.auto_role_rule_id} {rule.emoji_name} {interaction.guild.get_role(int(rule.role_id))}', value=rule.auto_role_rule_id) for rule in
|
||||
rules]
|
||||
server = self._servers.get_server_by_discord_id(interaction.guild.id)
|
||||
auto_roles = self._auto_roles.get_auto_roles_by_server_id(server.server_id).select(lambda x: x.auto_role_id)
|
||||
rules = auto_roles.select_many(lambda ar: self._auto_roles.get_auto_role_rules_by_auto_role_id(ar))
|
||||
return [app_commands.Choice(name=f'{rule.auto_role_rule_id} {rule.emoji_name} {interaction.guild.get_role(int(rule.role_id))}', value=rule.auto_role_rule_id) for rule in rules]
|
||||
|
Loading…
Reference in New Issue
Block a user