mirror of
https://github.com/Fluffy-Bean/Lynxie.git
synced 2025-05-20 18:34:56 +00:00
Add Dockerfile
Update blacklist Clean up e621 code
This commit is contained in:
parent
dbe660ded9
commit
d28a759f8e
24 changed files with 119 additions and 37 deletions
55
Bot/lynxie/commands/music.py
Normal file
55
Bot/lynxie/commands/music.py
Normal file
|
@ -0,0 +1,55 @@
|
|||
import yt_dlp
|
||||
import discord
|
||||
from discord.ext import commands
|
||||
from lynxie.utils import error_message
|
||||
|
||||
|
||||
ffmpeg_options = {"options": "-vn"}
|
||||
ydl_opts = {"format": "bestaudio"}
|
||||
ytdl = yt_dlp.YoutubeDL(ydl_opts)
|
||||
|
||||
|
||||
class Music(commands.Cog):
|
||||
def __init__(self, bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.command()
|
||||
async def join(self, ctx, *, channel: discord.VoiceChannel):
|
||||
if ctx.voice_client is not None:
|
||||
return await ctx.voice_client.move_to(channel)
|
||||
await channel.connect()
|
||||
|
||||
@commands.command()
|
||||
async def play(self, ctx, *, url):
|
||||
async with ctx.typing():
|
||||
song_info = ytdl.extract_info(url, download=False)
|
||||
ctx.voice_client.play(
|
||||
discord.FFmpegPCMAudio(song_info["url"], **ffmpeg_options)
|
||||
)
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Now playing",
|
||||
description=f"[{song_info['title']}]({song_info['webpage_url']})",
|
||||
color=discord.Color.orange(),
|
||||
)
|
||||
|
||||
await ctx.reply(embed=embed, mention_author=False)
|
||||
|
||||
@commands.command()
|
||||
async def stop(self, ctx):
|
||||
await ctx.voice_client.disconnect()
|
||||
|
||||
@play.before_invoke
|
||||
async def ensure_voice(self, ctx):
|
||||
if ctx.voice_client is None:
|
||||
if ctx.author.voice:
|
||||
await ctx.author.voice.channel.connect()
|
||||
else:
|
||||
error = "You are not connected to a voice channel."
|
||||
await ctx.reply(
|
||||
embed=error_message(error),
|
||||
mention_author=False,
|
||||
)
|
||||
return
|
||||
elif ctx.voice_client.is_playing():
|
||||
ctx.voice_client.stop()
|
Loading…
Add table
Add a link
Reference in a new issue