@commands.command(name="play") @commands.guild_only() @commands.bot_has_permissions(embed_links=True) async def command_play(self, ctx: commands.Context, *, query: str): """Play the specified track or search for a close match. To play a local track, the query should be `\\`. If you are the bot owner, use `[p]audioset info` to display your localtracks path. """ query = Query.process_input(query, self.local_folder_current_path) guild_data = await self.config.guild(ctx.guild).all() restrict = await self.config.restrict() if restrict and self.match_url(str(query)): valid_url = self.is_url_allowed(str(query)) if not valid_url: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_( "That URL is not allowed.\n\nThe bot owner can remove this restriction by using ``{prefix}audioset restrict``." ).format(prefix=ctx.clean_prefix), ) elif not await self.is_query_allowed(self.config, ctx, f"{query}", query_obj=query): return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("That track is not allowed.") ) can_skip = await self._can_instaskip(ctx, ctx.author) if guild_data["dj_enabled"] and not can_skip: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("You need the DJ role to queue tracks."), ) if not self._player_check(ctx): if self.lavalink_connection_aborted: msg = _("Connection to Lavalink node has failed") desc = None if await self.bot.is_owner(ctx.author): desc = _("Please check your console or logs for details.") return await self.send_embed_msg(ctx, title=msg, description=desc) try: if ( not self.can_join_and_speak(ctx.author.voice.channel) or not ctx.author.voice.channel.permissions_for(ctx.me).move_members and self.is_vc_full(ctx.author.voice.channel) ): return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_( "I don't have permission to connect and speak in your channel." ), ) await lavalink.connect( ctx.author.voice.channel, self_deaf=await self.config.guild_from_id(ctx.guild.id).auto_deafen(), ) except AttributeError: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("Connect to a voice channel first."), ) except NodeNotFound: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("Connection to the Lavalink node has not yet been established."), ) player = lavalink.get_player(ctx.guild.id) player.store("notify_channel", ctx.channel.id) await self._eq_check(ctx, player) await self.set_player_settings(ctx) if (not ctx.author.voice or ctx.author.voice.channel != player.channel) and not can_skip: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("You must be in the voice channel to use the play command."), ) if not query.valid: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("No tracks found for `{query}`.").format( query=query.to_string_user() ), ) if len(player.queue) >= 10000: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=_("Queue size limit reached.") ) if not await self.maybe_charge_requester(ctx, guild_data["jukebox_price"]): return if query.is_spotify: return await self._get_spotify_tracks(ctx, query) try: await self._enqueue_tracks(ctx, query) except QueryUnauthorized as exc: return await self.send_embed_msg( ctx, title=_("Unable To Play Tracks"), description=exc.message ) except Exception as e: self.update_player_lock(ctx, False) raise e