Compare commits
2 Commits
9db00516c3
...
1fc5ef76a6
Author | SHA1 | Date | |
---|---|---|---|
1fc5ef76a6 | |||
e6c9959381 |
@ -25,8 +25,8 @@ class ModuleList:
|
||||
[
|
||||
CoreModule, # has to be first!
|
||||
DataModule,
|
||||
ConfigModule, # has to be before db check
|
||||
DatabaseModule,
|
||||
ConfigModule, # has be to after db check
|
||||
GraphQLModule,
|
||||
PermissionModule,
|
||||
AutoRoleModule,
|
||||
|
@ -4,6 +4,7 @@ import discord
|
||||
from cpl_discord.command import DiscordCommandABC
|
||||
from cpl_discord.service import DiscordBotServiceABC
|
||||
from cpl_translation import TranslatePipe
|
||||
from discord.app_commands import Transform
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands import Context
|
||||
|
||||
@ -11,6 +12,7 @@ from bot_core.abc.message_service_abc import MessageServiceABC
|
||||
from bot_core.helper.command_checks import CommandChecks
|
||||
from bot_core.logging.command_logger import CommandLogger
|
||||
from bot_core.service.client_utils_service import ClientUtilsService
|
||||
from modules.base.helper.voice_channel_transformer import VoiceChannelTransformer
|
||||
|
||||
|
||||
class MassMoveCommand(DiscordCommandABC):
|
||||
@ -36,7 +38,7 @@ class MassMoveCommand(DiscordCommandABC):
|
||||
self,
|
||||
ctx: Context,
|
||||
channel_to: discord.VoiceChannel,
|
||||
channel_from: discord.VoiceChannel = None,
|
||||
channel_from: Transform[str, VoiceChannelTransformer] = None,
|
||||
):
|
||||
self._logger.debug(__name__, f"Received command mass-move {ctx}")
|
||||
|
||||
|
30
kdb-bot/src/modules/base/helper/voice_channel_transformer.py
Normal file
30
kdb-bot/src/modules/base/helper/voice_channel_transformer.py
Normal file
@ -0,0 +1,30 @@
|
||||
import discord
|
||||
from cpl_core.dependency_injection import ServiceProviderABC
|
||||
from cpl_query.extension import List
|
||||
from discord import Interaction, app_commands
|
||||
from discord.app_commands import Transformer, Choice
|
||||
|
||||
from bot_core.abc.client_utils_abc import ClientUtilsABC
|
||||
|
||||
|
||||
class VoiceChannelTransformer(Transformer):
|
||||
async def transform(self, interaction: Interaction, value: str, /) -> discord.VoiceChannel:
|
||||
voice_channel = (
|
||||
List(discord.VoiceChannel, interaction.guild.voice_channels)
|
||||
.where(lambda x: str(x.id) == value)
|
||||
.first_or_default()
|
||||
)
|
||||
return voice_channel
|
||||
|
||||
async def autocomplete(self, interaction: Interaction, current: str, /) -> list[Choice[str]]:
|
||||
@ServiceProviderABC.inject
|
||||
def get_client_utils(client_utils: ClientUtilsABC) -> ClientUtilsABC:
|
||||
return client_utils
|
||||
|
||||
voice_channels = List(discord.Role, interaction.guild.voice_channels).where(lambda x: len(x.members) > 0)
|
||||
return [
|
||||
app_commands.Choice(
|
||||
name=f"{vc.name}" if vc.category is None else f"{vc.name}: {vc.category.name}", value=vc.name
|
||||
)
|
||||
for vc in get_client_utils().get_auto_complete_list(voice_channels, current, lambda x: x.name)
|
||||
]
|
Loading…
Reference in New Issue
Block a user