Added react command
This commit is contained in:
parent
3d9cd0a2fc
commit
7e6053768f
@ -123,6 +123,9 @@
|
||||
},
|
||||
"success": "auto-role {} wurde entfernt :D"
|
||||
},
|
||||
"react": {
|
||||
"success": "Alle Reaktionen wurden hinzugefügt",
|
||||
},
|
||||
"rule": {
|
||||
"add": {
|
||||
"error": {
|
||||
|
@ -220,6 +220,48 @@ class AutoRoleGroup(DiscordCommandABC):
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
return await self._auto_role_auto_complete(interaction, current)
|
||||
|
||||
@auto_role.command("react")
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
@CommandChecks.check_is_member_moderator()
|
||||
async def react(self, ctx: Context, auto_role: int):
|
||||
self._logger.debug(__name__, f"Received command auto-role react {ctx} {auto_role}")
|
||||
if ctx.guild is None:
|
||||
return
|
||||
|
||||
server_config: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||
if not FeatureFlagsSettings.get_flag_from_dict(server_config.feature_flags, FeatureFlagsEnum.auto_role_module):
|
||||
return
|
||||
|
||||
auto_role_from_db = self._auto_roles.find_auto_role_by_id(auto_role)
|
||||
if auto_role_from_db is None:
|
||||
self._logger.debug(__name__, f"auto-role {auto_role} not found")
|
||||
await self._message_service.send_ctx_msg(
|
||||
ctx,
|
||||
self._t.transform("modules.auto_role.remove.error.not_found").format(auto_role),
|
||||
)
|
||||
self._logger.trace(__name__, f"Finished command auto-role react")
|
||||
return
|
||||
|
||||
for rule in self._auto_roles.get_auto_role_rules_by_auto_role_id(auto_role_from_db.id):
|
||||
self._bot.loop.create_task(
|
||||
await self._client_utils.react_to_message_by_auto_role_rule(
|
||||
auto_role_from_db.discord_channel_id, auto_role_from_db.discord_message_id, rule, ctx.guild
|
||||
)
|
||||
)
|
||||
|
||||
await self._message_service.send_ctx_msg(
|
||||
ctx,
|
||||
self._t.transform("modules.auto_role.react.success"),
|
||||
)
|
||||
self._logger.trace(__name__, f"Finished command auto-role react")
|
||||
|
||||
@remove.autocomplete("auto_role")
|
||||
async def react_autocomplete(
|
||||
self, interaction: discord.Interaction, current: str
|
||||
) -> TList[app_commands.Choice[str]]:
|
||||
return await self._auto_role_auto_complete(interaction, current)
|
||||
|
||||
@auto_role.group()
|
||||
@commands.guild_only()
|
||||
async def rule(self, ctx: Context):
|
||||
|
Loading…
Reference in New Issue
Block a user