From dd08ae4bc3a032ea92ba5f4120f8f9207c752753 Mon Sep 17 00:00:00 2001 From: Ev-1 <33662061+Ev-1@users.noreply.github.com> Date: Tue, 18 May 2021 18:14:06 +0200 Subject: [PATCH] Make the bot say which voice channel it is currently being used in. --- cogs/errors.py | 29 +++++++++++++++-------------- cogs/music/decorators.py | 4 +++- 2 files changed, 18 insertions(+), 15 deletions(-) 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/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)