Fix autocompletion in all slash commands
This commit is contained in:
@@ -68,7 +68,7 @@ class Admin(commands.Cog, name="settings"):
|
|||||||
await ctx.send(get_lang(ctx.guild.id, 'changedLanguage').format(language))
|
await ctx.send(get_lang(ctx.guild.id, 'changedLanguage').format(language))
|
||||||
|
|
||||||
@language.autocomplete('language')
|
@language.autocomplete('language')
|
||||||
async def autocomplete_callback(self, ctx: commands.Context, current: str) -> list:
|
async def autocomplete_callback(self, interaction: discord.Interaction, current: str) -> list:
|
||||||
if current:
|
if current:
|
||||||
return [app_commands.Choice(name=lang, value=lang) for lang in langs.keys() if current.upper() in lang]
|
return [app_commands.Choice(name=lang, value=lang) for lang in langs.keys() if current.upper() in lang]
|
||||||
return [app_commands.Choice(name=lang, value=lang) for lang in langs.keys()]
|
return [app_commands.Choice(name=lang, value=lang) for lang in langs.keys()]
|
||||||
|
|||||||
@@ -52,10 +52,6 @@ async def nowplay(ctx: commands.Context, player: voicelink.Player):
|
|||||||
|
|
||||||
return await ctx.send(embed=embed, view=LinkView(player.get_msg('nowplayingLink').format(track.source), track.emoji, track.uri))
|
return await ctx.send(embed=embed, view=LinkView(player.get_msg('nowplayingLink').format(track.source), track.emoji, track.uri))
|
||||||
|
|
||||||
|
|
||||||
async def help_autocomplete(ctx: commands.Context, current: str) -> list:
|
|
||||||
return [app_commands.Choice(name=c.capitalize(), value=c) for c in ctx.bot.cogs if c not in ["Nodes", "Task"] and current in c]
|
|
||||||
|
|
||||||
class Basic(commands.Cog):
|
class Basic(commands.Cog):
|
||||||
def __init__(self, bot: commands.Bot) -> None:
|
def __init__(self, bot: commands.Bot) -> None:
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
@@ -70,6 +66,9 @@ class Basic(commands.Cog):
|
|||||||
self.bot.tree.remove_command(
|
self.bot.tree.remove_command(
|
||||||
self.ctx_menu.name, type=self.ctx_menu.type)
|
self.ctx_menu.name, type=self.ctx_menu.type)
|
||||||
|
|
||||||
|
async def help_autocomplete(self, interaction: discord.Interaction, current: str) -> list:
|
||||||
|
return [app_commands.Choice(name=c.capitalize(), value=c) for c in self.bot.cogs if c not in ["Nodes", "Task"] and current in c]
|
||||||
|
|
||||||
@commands.hybrid_command(name="connect", aliases=get_aliases("connect"))
|
@commands.hybrid_command(name="connect", aliases=get_aliases("connect"))
|
||||||
@app_commands.describe(channel="Provide a channel to connect.")
|
@app_commands.describe(channel="Provide a channel to connect.")
|
||||||
@commands.dynamic_cooldown(cooldown_check, commands.BucketType.guild)
|
@commands.dynamic_cooldown(cooldown_check, commands.BucketType.guild)
|
||||||
|
|||||||
@@ -27,8 +27,8 @@ class Effect(commands.Cog):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.description = "This category is only available to DJ on this server. (You can setdj on your server by /settings setdj <DJ ROLE>)"
|
self.description = "This category is only available to DJ on this server. (You can setdj on your server by /settings setdj <DJ ROLE>)"
|
||||||
|
|
||||||
async def effect_autocomplete(self, ctx: commands.Context, current: str) -> list:
|
async def effect_autocomplete(self, interaction: discord.Interaction, current: str) -> list:
|
||||||
player: voicelink.Player = ctx.guild.voice_client
|
player: voicelink.Player = interaction.guild.voice_client
|
||||||
if not player:
|
if not player:
|
||||||
return []
|
return []
|
||||||
if current:
|
if current:
|
||||||
|
|||||||
@@ -74,19 +74,21 @@ class Playlists(commands.Cog, name="playlist"):
|
|||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.description = "This is the Vocard playlist system. You can save your favorites and use Vocard to play on any server."
|
self.description = "This is the Vocard playlist system. You can save your favorites and use Vocard to play on any server."
|
||||||
|
|
||||||
async def playlist_autocomplete(self, ctx: commands.Context, current: str) -> list:
|
async def playlist_autocomplete(self, interaction: discord.Interaction, current: str) -> list:
|
||||||
playlists = playlist_name.get(str(ctx.author.id), None)
|
playlists = playlist_name.get(str(interaction.user.id), None)
|
||||||
if not playlists:
|
if not playlists:
|
||||||
playlists_raw = await get_playlist(ctx.author.id, 'playlist')
|
playlists_raw = await get_playlist(interaction.user.id, 'playlist')
|
||||||
playlists = playlist_name[str(ctx.author.id)] = [
|
playlists = playlist_name[str(interaction.user.id)] = [
|
||||||
value['name'] for value in playlists_raw.values()] if playlists_raw else []
|
value['name'] for value in playlists_raw.values()] if playlists_raw else []
|
||||||
if current:
|
if current:
|
||||||
return [app_commands.Choice(name=p, value=p) for p in playlists if current in p]
|
return [app_commands.Choice(name=p, value=p) for p in playlists if current in p]
|
||||||
return [app_commands.Choice(name=p, value=p) for p in playlists]
|
return [app_commands.Choice(name=p, value=p) for p in playlists]
|
||||||
|
|
||||||
@commands.hybrid_group(name="playlist",
|
@commands.hybrid_group(
|
||||||
aliases=get_aliases("playlist"),
|
name="playlist",
|
||||||
invoke_without_command=True)
|
aliases=get_aliases("playlist"),
|
||||||
|
invoke_without_command=True
|
||||||
|
)
|
||||||
async def playlist(self, ctx: commands.Context):
|
async def playlist(self, ctx: commands.Context):
|
||||||
view = HelpView(self.bot, ctx.author)
|
view = HelpView(self.bot, ctx.author)
|
||||||
embed = view.build_embed(self.qualified_name)
|
embed = view.build_embed(self.qualified_name)
|
||||||
|
|||||||
Reference in New Issue
Block a user