master #475
@ -1,3 +1,4 @@
|
||||
import discord
|
||||
from cpl_core.configuration import ConfigurationABC
|
||||
from cpl_discord.command import DiscordCommandABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
@ -8,6 +9,7 @@ from discord.ext.commands import Context
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.abc.permission_service_abc import PermissionServiceABC
|
||||
from bot_core.helper.command_checks import CommandChecks
|
||||
from bot_core.logging.command_logger import CommandLogger
|
||||
from bot_data.model.server_config import ServerConfig
|
||||
@ -22,6 +24,7 @@ class AFKCommand(DiscordCommandABC):
|
||||
bot: DiscordBotServiceABC,
|
||||
client_utils: ClientUtilsABC,
|
||||
translate: TranslatePipe,
|
||||
permissions: PermissionServiceABC,
|
||||
):
|
||||
DiscordCommandABC.__init__(self)
|
||||
|
||||
@ -29,6 +32,7 @@ class AFKCommand(DiscordCommandABC):
|
||||
self._config = config
|
||||
self._message_service = message_service
|
||||
self._bot = bot
|
||||
self._permissions = permissions
|
||||
self._client_utils = client_utils
|
||||
self._t = translate
|
||||
|
||||
@ -37,7 +41,12 @@ class AFKCommand(DiscordCommandABC):
|
||||
@commands.hybrid_command()
|
||||
@commands.guild_only()
|
||||
@CommandChecks.check_is_ready()
|
||||
async def afk(self, ctx: Context):
|
||||
async def afk(self, ctx: Context, member: discord.Member = None):
|
||||
is_mod = self._permissions.is_member_moderator(ctx.author)
|
||||
if member is not None and not is_mod:
|
||||
await self._message_service.send_ctx_msg(ctx, self._t.transform("common.no_permission_message"))
|
||||
return
|
||||
|
||||
self._logger.debug(__name__, f"Received command afk {ctx}")
|
||||
settings: ServerConfig = self._config.get_configuration(f"ServerConfig_{ctx.guild.id}")
|
||||
|
||||
@ -54,7 +63,10 @@ class AFKCommand(DiscordCommandABC):
|
||||
)
|
||||
channel: VoiceChannel = ctx.guild.get_channel(settings.afk_command_channel_id)
|
||||
try:
|
||||
await ctx.author.move_to(channel)
|
||||
if member is not None:
|
||||
await member.move_to(channel)
|
||||
else:
|
||||
await ctx.author.move_to(channel)
|
||||
self._client_utils.moved_user(ctx.guild.id)
|
||||
except Exception as e:
|
||||
self._logger.error(
|
||||
|
Loading…
Reference in New Issue
Block a user