Repository: Cog-Creators/Red-DiscordBot

Issue:
[Audio] Shuffle command shows error, but changes the setting anyway
# Command bugs

#### Command name

`[p]shuffle`

#### What cog is this command from?

Audio

#### What were you expecting to happen?

Not sure, but I'm sure that this error should mean that the setting shouldn't be changed.

#### What actually happened?

The setting got changed despite the error

#### How can we reproduce this issue?

Use these commands with a user that can't instaskip (and with DJ role disabled) and see that the "Shuffle" setting gets changed despite the error:
```
[p]audioset settings
[p]shuffle
[p]audioset settings
```
Here's screenshot:
![image](https://user-images.githubusercontent.com/6032823/60299725-b4f45400-992d-11e9-8a32-2ea35cf942d8.png)




Discussion:

Resolving patch:
diff --git a/redbot/cogs/audio/audio.py b/redbot/cogs/audio/audio.py
--- a/redbot/cogs/audio/audio.py
+++ b/redbot/cogs/audio/audio.py
@@ -2819,9 +2819,6 @@ async def repeat(self, ctx):
                 ctx, ctx.author
             ):
                 return await self._embed_msg(ctx, _("You need the DJ role to toggle repeat."))
-        repeat = await self.config.guild(ctx.guild).repeat()
-        await self.config.guild(ctx.guild).repeat.set(not repeat)
-        repeat = await self.config.guild(ctx.guild).repeat()
         if self._player_check(ctx):
             await self._data_check(ctx)
             player = lavalink.get_player(ctx.guild.id)
@@ -2831,9 +2828,13 @@ async def repeat(self, ctx):
                 return await self._embed_msg(
                     ctx, _("You must be in the voice channel to toggle repeat.")
                 )
+
+        repeat = await self.config.guild(ctx.guild).repeat()
+        await self.config.guild(ctx.guild).repeat.set(not repeat)
         await self._embed_msg(
-            ctx, _("Repeat tracks: {true_or_false}.").format(true_or_false=repeat)
+            ctx, _("Repeat tracks: {true_or_false}.").format(true_or_false=not repeat)
         )
+        await self._data_check(ctx)
 
     @commands.command()
     @commands.guild_only()
@@ -3245,9 +3246,6 @@ async def shuffle(self, ctx):
         if dj_enabled:
             if not await self._can_instaskip(ctx, ctx.author):
                 return await self._embed_msg(ctx, _("You need the DJ role to toggle shuffle."))
-        shuffle = await self.config.guild(ctx.guild).shuffle()
-        await self.config.guild(ctx.guild).shuffle.set(not shuffle)
-        shuffle = await self.config.guild(ctx.guild).shuffle()
         if self._player_check(ctx):
             await self._data_check(ctx)
             player = lavalink.get_player(ctx.guild.id)
@@ -3257,9 +3255,13 @@ async def shuffle(self, ctx):
                 return await self._embed_msg(
                     ctx, _("You must be in the voice channel to toggle shuffle.")
                 )
+
+        shuffle = await self.config.guild(ctx.guild).shuffle()
+        await self.config.guild(ctx.guild).shuffle.set(not shuffle)
         await self._embed_msg(
-            ctx, _("Shuffle tracks: {true_or_false}.").format(true_or_false=shuffle)
+            ctx, _("Shuffle tracks: {true_or_false}.").format(true_or_false=not shuffle)
         )
+        await self._data_check(ctx)
 
     @commands.command()
     @commands.guild_only()


Test patch: