diff --git a/cogs/basic.py b/cogs/basic.py index eeaef08..35f0444 100644 --- a/cogs/basic.py +++ b/cogs/basic.py @@ -13,7 +13,8 @@ from function import ( get_lang, embed_color, cooldown_check, - get_aliases + get_aliases, + connect_channel ) from addons import getLyrics @@ -28,20 +29,6 @@ searchPlatform = { "apple": "amsearch", } -async def connect_channel(ctx: commands.Context, channel: discord.VoiceChannel = None) -> voicelink.Player: - try: - channel = channel or ctx.author.voice.channel - except: - raise voicelink.VoicelinkException(get_lang(ctx.guild.id, 'noChannel')) - - check = channel.permissions_for(ctx.guild.me) - if check.connect == False or check.speak == False: - raise voicelink.VoicelinkException( - get_lang(ctx.guild.id, 'noPermission')) - - player: voicelink.Player = await channel.connect(cls=voicelink.Player(ctx.bot, channel, ctx)) - return player - async def nowplay(ctx: commands.Context, player: voicelink.Player): track = player.current if not track: @@ -223,9 +210,7 @@ class Basic(commands.Cog): await player.do_next() @commands.hybrid_command(name="playtop", aliases=get_aliases("playtop")) - @app_commands.describe( - query="Input the name of the song.", - ) + @app_commands.describe(query="Input a query or a searchable link.") @commands.dynamic_cooldown(cooldown_check, commands.BucketType.guild) async def playtop(self, ctx: commands.Context, query: str): "Adds a song with the given url or query on the top of the queue." diff --git a/cogs/playlist.py b/cogs/playlist.py index d050418..d027c72 100644 --- a/cogs/playlist.py +++ b/cogs/playlist.py @@ -15,7 +15,8 @@ from function import ( playlist_name, embed_color, get_aliases, - cooldown_check + cooldown_check, + connect_channel ) from datetime import datetime @@ -68,23 +69,6 @@ async def search_playlist(url: str, requester: discord.Member, timeNeed=True): return None return tracks | ({'time': ctime(time)} if timeNeed else {}) - -async def connect_channel(ctx: commands.Context, channel: discord.VoiceChannel = None) -> voicelink.Player: - try: - channel = channel or ctx.author.voice.channel - except: - raise voicelink.VoicelinkException( - get_lang(ctx.guild.id, 'noChannel')) - - check = channel.permissions_for(ctx.guild.me) - if check.connect == False or check.speak == False: - raise voicelink.VoicelinkException( - get_lang(ctx.guild.id, 'noPermission')) - - player: voicelink.Player = await channel.connect(cls=voicelink.Player(ctx.bot, channel, ctx)) - return player - - class Playlists(commands.Cog, name="playlist"): def __init__(self, bot: commands.Bot) -> None: self.bot = bot diff --git a/function.py b/function.py index 73a7828..b0ec94b 100644 --- a/function.py +++ b/function.py @@ -219,6 +219,21 @@ async def similar_track(player) -> bool: return False +async def connect_channel(ctx: commands.Context, channel: discord.VoiceChannel = None): + import voicelink + try: + channel = channel or ctx.author.voice.channel + except: + raise voicelink.VoicelinkException(get_lang(ctx.guild.id, 'noChannel')) + + check = channel.permissions_for(ctx.guild.me) + if check.connect == False or check.speak == False: + raise voicelink.VoicelinkException( + get_lang(ctx.guild.id, 'noPermission')) + + player: voicelink.Player = await channel.connect(cls=voicelink.Player(ctx.bot, channel, ctx)) + return player + def time(millis:int) -> str: seconds=(millis/1000)%60 minutes=(millis/(1000*60))%60