diff --git a/cogs/errors.py b/cogs/errors.py index d538c8e..5f69570 100644 --- a/cogs/errors.py +++ b/cogs/errors.py @@ -55,9 +55,6 @@ class Errors(commands.Cog): elif (err.original == 'I need the `CONNECT` and `SPEAK` permissions.'): return await send_error_embed('{errors.need_permission}') - elif (err.original == 'You need to be in my voicechannel.'): - return await send_error_embed('{errors.my_channel}') - elif (err.original == 'Not playing'): return await send_error_embed('{not_playing}') @@ -68,17 +65,21 @@ class Errors(commands.Cog): return await send_error_embed('{errors.full_channel}') if isinstance(err, WrongVoiceChannelError): - changed = False - response = ctx.localizer.format_str('{settings_check.voicechannel}') - for channel_id in err.channels: - channel = ctx.guild.get_channel(channel_id) - if channel is not None: - response += f'{channel.name}, ' - changed = True - if changed: - return await send_error_embed(response[:-2], title='{errors.right_channel}') - else: - return await send_error_embed('{errors.right_channel}') + if(err.original.startswith("You need to be in my voice channel")): + return await send_error_embed(err.channels[0].name, title='{errors.my_channel}') + + elif (err.original.startswith('You need to be in the right voice channel')): + changed = False + response = ctx.localizer.format_str('{settings_check.voicechannel}') + for channel_id in err.channels: + channel = ctx.guild.get_channel(channel_id) + if channel is not None: + response += f'{channel.name}, ' + changed = True + if changed: + return await send_error_embed(response[:-2], title='{errors.right_channel}') + else: + return await send_error_embed('{errors.right_channel}') if isinstance(err, WrongTextChannelError): try: diff --git a/cogs/music/__init__.py b/cogs/music/__init__.py index 7e3bf7f..4bd0ba4 100644 --- a/cogs/music/__init__.py +++ b/cogs/music/__init__.py @@ -120,8 +120,8 @@ class Music(commands.Cog): # commands from .basic_commands import ( - _disconnect, _djremove, _forceplay, _move, _myqueue, _now, _pause, _play, _queue, _reconnect, _remove, _search, - _seek, _shuffle, _skip, _skip_to, _stop, _user_queue_remove, _volume) + _disconnect, _djremove, _forcedisconnect, _forceplay, _move, _myqueue, _now, _pause, _play, _queue, _reconnect, + _remove, _search, _seek, _shuffle, _skip, _skip_to, _stop, _user_queue_remove, _volume) # events from .events import check_leave_voice, cog_unload, leave_check, leave_timer, on_voice_state_update, track_hook # commands diff --git a/cogs/music/basic_commands.py b/cogs/music/basic_commands.py index 4507c20..ff5761a 100644 --- a/cogs/music/basic_commands.py +++ b/cogs/music/basic_commands.py @@ -439,3 +439,19 @@ async def _forceplay(self, ctx, *, query: str): if not player.is_playing: await player.play() + + +@commands.command(name='forcedisconnect') +@checks.dj_or(alone=True) +async def _forcedisconnect(self, ctx): + """ Attempts to force disconnect the bot without checking if it is connected initially. """ + try: + player = self.bot.lavalink.player_manager.get(ctx.guild.id) + player.queue.clear() + await player.stop() + except Exception: + self.logger.exception("Error forcedisconnecting") + await self.connect_to(ctx.guild.id, None) + embed = discord.Embed(description='{disconnect.disconnected}', color=ctx.me.color) + embed = ctx.localizer.format_embed(embed) + await ctx.send(embed=embed) diff --git a/cogs/music/decorators.py b/cogs/music/decorators.py index 6db999d..0b503ba 100644 --- a/cogs/music/decorators.py +++ b/cogs/music/decorators.py @@ -49,7 +49,9 @@ def require_voice_connection(should_connect=False): await self.connect_to(ctx.guild.id, str(ctx.author.voice.channel.id)) elif int(player.channel_id) != ctx.author.voice.channel.id: - raise commands.CommandInvokeError('You need to be in my voicechannel.') + bot_channel = self.bot.get_channel(int(player.channel_id)) + raise WrongVoiceChannelError( + 'You need to be in my voice channel', channels=[bot_channel]) await func(self, ctx, *command_args, **kwargs) diff --git a/cogs/settings.py b/cogs/settings.py index 5c10453..6e87c66 100644 --- a/cogs/settings.py +++ b/cogs/settings.py @@ -3,7 +3,9 @@ import discord from discord.ext import commands # Bot Utilities +from cogs.helpformatter import commandhelper from cogs.utils import checks +from cogs.utils.paginator import Scroller class Settings(commands.Cog): @@ -22,7 +24,10 @@ class Settings(commands.Cog): @commands.group(name='settings', hidden=True) async def _set(self, ctx): if ctx.invoked_subcommand is None: - await self.current_settings.invoke(ctx) + ctx.localizer.prefix = 'help' # Ensure the bot looks for locales in the context of help, not cogmanager. + paginator = commandhelper(ctx, ctx.command, ctx.invoker, include_subcmd=True) + scroller = Scroller(ctx, paginator) + await scroller.start_scrolling() @checks.is_admin() @commands.guild_only()