mirror of
https://github.com/UiO-Gaming/ShiteMusicBot.git
synced 2026-11-05 13:56:51 +01:00
Even more prep for merge
This commit is contained in:
1 parent
16d2b9af0d
commit
43c166a2a1
1 file changed
+46
-15
+46
-15
@@ -13,6 +13,8 @@ import re
|
||||
import time
|
||||
import asyncio
|
||||
from cogs.utils import RoxUtils
|
||||
from .utils.mixplayer.mixplayer import MixPlayer
|
||||
from .utils import checks
|
||||
|
||||
import discord
|
||||
import lavalink
|
||||
@@ -28,8 +30,11 @@ class Music:
|
||||
self.bot = bot
|
||||
|
||||
if not hasattr(bot, 'lavalink'):
|
||||
lavalink.Client(bot=bot, password='youshallnotpass', loop=bot.loop, log_level=logging.INFO,
|
||||
host=host, ws_port=ws_port, rest_port=rest_port)
|
||||
lavalink.Client(bot=bot, password='youshallnotpass',
|
||||
loop=bot.loop, log_level=logging.INFO,
|
||||
host=host, ws_port=ws_port,
|
||||
rest_port=rest_port,
|
||||
player=MixPlayer)
|
||||
self.bot.lavalink.register_hook(self._track_hook)
|
||||
|
||||
def __unload(self):
|
||||
@@ -136,19 +141,17 @@ class Music:
|
||||
|
||||
await player.play_now(requester=ctx.author.id, track=track)
|
||||
|
||||
@commands.command(name='playat', aliases=['pa'])
|
||||
@commands.command(name='skipto', aliases=['st'])
|
||||
@commands.guild_only()
|
||||
async def _playat(self, ctx, index: int):
|
||||
@checks.is_DJ()
|
||||
async def _skip_to(self, ctx, index: int):
|
||||
""" Plays the queue from a specific point. Disregards tracks before the index. """
|
||||
player = self.bot.lavalink.players.get(ctx.guild.id)
|
||||
|
||||
if index < 1:
|
||||
return await ctx.send('Invalid specified index.')
|
||||
|
||||
if len(player.queue) < index:
|
||||
return await ctx.send('This index exceeds the queue\'s length.')
|
||||
|
||||
await player.play_at(index-1)
|
||||
await player.skip_to(index - 1)
|
||||
|
||||
@commands.command(name='seek')
|
||||
@commands.guild_only()
|
||||
@@ -226,21 +229,49 @@ class Music:
|
||||
""" Shows the player's queue. """
|
||||
player = self.bot.lavalink.players.get(ctx.guild.id)
|
||||
|
||||
if not player.queue:
|
||||
if player.queue.is_empty():
|
||||
return await ctx.send('There\'s nothing in the queue! Why not queue something?')
|
||||
|
||||
queue = player.queue.get_queue()
|
||||
items_per_page = 10
|
||||
pages = math.ceil(len(player.queue) / items_per_page)
|
||||
|
||||
pages = math.ceil(len(queue) / items_per_page)
|
||||
start = (page - 1) * items_per_page
|
||||
end = start + items_per_page
|
||||
|
||||
queue_list = ''
|
||||
for index, track in enumerate(player.queue[start:end], start=start):
|
||||
queue_list += f'`{index + 1}.` [**{track.title}**]({track.uri})\n'
|
||||
for index, track in enumerate(queue[start:end], start=start):
|
||||
queue_list += f'`{index + 1}.` [**{track.title}**]({track.uri}) _by <@{track.requester}>_\n'
|
||||
|
||||
embed = discord.Embed(colour=0xEFD26C,
|
||||
description=f'**{len(player.queue)} tracks**\n\n{queue_list}')
|
||||
embed = discord.Embed(color=0xEFD26C,
|
||||
description=f'**{len(queue)} tracks**\n\n{queue_list}')
|
||||
embed.set_footer(text=f'Viewing page {page}/{pages}')
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
@commands.command(name='myqueue', aliases=['mq'])
|
||||
@commands.guild_only()
|
||||
async def _myqueue(self, ctx, page: int = 1):
|
||||
""" Shows the player's queue. """
|
||||
player = self.bot.lavalink.players.get(ctx.guild.id)
|
||||
|
||||
if player.queue.is_empty():
|
||||
return await ctx.send('There\'s nothing in the queue! Why not queue something?')
|
||||
|
||||
queue = player.queue.get_user_queue(ctx.author.id, pos=True)
|
||||
|
||||
if not queue:
|
||||
return await ctx.send('You haven\'t queued anything')
|
||||
|
||||
items_per_page = 10
|
||||
pages = math.ceil(len(queue) / items_per_page)
|
||||
start = (page - 1) * items_per_page
|
||||
end = start + items_per_page
|
||||
|
||||
queue_list = ''
|
||||
for index, (track, globalpos) in enumerate(queue[start:end], start=start):
|
||||
queue_list += f'`{index + 1}({globalpos + 1}).` [**{track.title}**]({track.uri})\n'
|
||||
|
||||
embed = discord.Embed(color=0xEFD26C,
|
||||
description=f'**{len(queue)} tracks**\n\n{queue_list}')
|
||||
embed.set_footer(text=f'Viewing page {page}/{pages}')
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
|
||||
Reference in new issue
Block a user