Skip to content

Commit

Permalink
Added shuffle command
Browse files Browse the repository at this point in the history
  • Loading branch information
Fluxticks committed Jul 27, 2021
1 parent 3124086 commit d817eef
Showing 1 changed file with 17 additions and 0 deletions.
17 changes: 17 additions & 0 deletions src/esportsbot/cogs/MusicCog.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
import sys
import time
from enum import IntEnum
from random import shuffle
from urllib.parse import parse_qs, urlparse

import googleapiclient.discovery
Expand Down Expand Up @@ -817,6 +818,22 @@ async def __set_volume(self, guild_id, volume_level):

self.active_guilds.get(guild_id).get("voice_client").source.volume = float(volume_level) / float(100)

@command_group.command(
name="shuffle",
help="Shuffles the current queue."
)
async def shuffle_queue(self, context: commands.Context):
if context.author in self.active_guilds.get(context.guild.id).get("voice_channel").members:
await self.__shuffle_queue(context.guild.id)
await send_timed_message(channel=context.channel, content=self.user_strings["shuffle_queue_success"], timer=10)

async def __shuffle_queue(self, guild_id):
if guild_id not in self.active_guilds:
return

shuffle(self.active_guilds.get(guild_id).get("queue"))
await self.update_messages(guild_id)

@staticmethod
async def clear_music_channel(channel):
await channel.purge(limit=int(sys.maxsize))
Expand Down

0 comments on commit d817eef

Please sign in to comment.