0.3 #146

Merged
edraft merged 359 commits from 0.3 into master 2023-01-12 07:04:40 +01:00
2 changed files with 16 additions and 8 deletions
Showing only changes of commit f551fdf87b - Show all commits

View File

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

View File

@ -66,12 +66,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')
@ -165,7 +169,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()
@ -212,7 +217,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()
@ -259,7 +265,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')
@ -299,6 +306,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]