finished queue system, overwrites discord kill process to loop
This commit is contained in:
@@ -1,20 +1,15 @@
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from discord.ext.commands.context import Context
|
||||
|
||||
import cogs.music.util as util
|
||||
import cogs.music.queue as queue
|
||||
import cogs.music.translate as translate
|
||||
|
||||
import datetime
|
||||
import pytz
|
||||
|
||||
import yt_dlp
|
||||
|
||||
from cogs.music.help import music_help
|
||||
|
||||
ydl_opts = {
|
||||
'format': 'bestaudio/best',
|
||||
'outtmpl': 'downloads/%(title)s.%(ext)s',
|
||||
}
|
||||
|
||||
class music(commands.Cog):
|
||||
def __init__(self, client):
|
||||
@@ -27,6 +22,8 @@ class music(commands.Cog):
|
||||
help_command.cog = self
|
||||
self.help_command = help_command
|
||||
|
||||
queue.initialize_tables()
|
||||
|
||||
|
||||
@commands.command(
|
||||
help="Displays latency from the bot",
|
||||
@@ -59,20 +56,26 @@ class music(commands.Cog):
|
||||
@commands.command(
|
||||
help="Queues a song into the bot",
|
||||
aliases=['p', 'qeue', 'q'])
|
||||
@commands.check(util.in_server)
|
||||
async def play(self, ctx: Context, *, url=None):
|
||||
if url is None:
|
||||
raise commands.CommandError("Must provide a link or search query")
|
||||
|
||||
server = ctx.guild.id
|
||||
|
||||
#TODO potentially save requests before getting stream link
|
||||
audio = translate.main(url)
|
||||
|
||||
#TODO make sure user isn't queuing in dm for some stupid reason
|
||||
for song in audio:
|
||||
await queue.add_song(server, song, ctx.author.id)
|
||||
|
||||
await ctx.message.add_reaction('👍')
|
||||
|
||||
await util.join_vc(ctx)
|
||||
|
||||
if await queue.is_server_playing(ctx.guild.id):
|
||||
return
|
||||
|
||||
with yt_dlp.YoutubeDL(ydl_opts) as ydl:
|
||||
info = ydl.extract_info(url, download=True)
|
||||
filename = ydl.prepare_filename(info)
|
||||
|
||||
ctx.voice_client.play(discord.FFmpegPCMAudio(executable="ffmpeg", source=filename), after=self.test)
|
||||
|
||||
|
||||
def test(self, error):
|
||||
print("Hello")
|
||||
await queue.update_server(server, True)
|
||||
await queue.play(ctx)
|
||||
|
||||
Reference in New Issue
Block a user