82 lines
1.9 KiB
Python
82 lines
1.9 KiB
Python
import inf0
|
|
import discord
|
|
import os
|
|
from discord.ext import commands
|
|
from discord.utils import get
|
|
from discord import FFmpegPCMAudio
|
|
from discord import TextChannel
|
|
from youtube_dl import YoutubeDL
|
|
|
|
client = commands.Bot(command_prefix='ç')
|
|
|
|
players = {}
|
|
|
|
|
|
@client.event
|
|
async def on_ready():
|
|
print('Capitán Teemo de servicio!')
|
|
|
|
|
|
@client.command()
|
|
async def join(ctx):
|
|
channel = ctx.message.author.voice.channel
|
|
voice = get(client.voice_clients, guild=ctx.guild)
|
|
if voice and voice.is_connected():
|
|
await voice.move_to(channel)
|
|
else:
|
|
voice = await channel.connect()
|
|
|
|
|
|
@client.command()
|
|
async def play(ctx, url):
|
|
YDL_OPTIONS = {'format': 'bestaudio', 'noplaylist': 'True'}
|
|
FFMPEG_OPTIONS = {
|
|
'before_options': '-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5', 'options': '-vn'}
|
|
voice = get(client.voice_clients, guild=ctx.guild)
|
|
|
|
if not voice.is_playing():
|
|
with YoutubeDL(YDL_OPTIONS) as ydl:
|
|
info = ydl.extract_info(url, download=False)
|
|
URL = info['url']
|
|
voice.play(FFmpegPCMAudio(URL, **FFMPEG_OPTIONS))
|
|
voice.is_playing()
|
|
await ctx.send('._.')
|
|
|
|
else:
|
|
await ctx.send("._.")
|
|
return
|
|
|
|
|
|
@client.command()
|
|
async def resume(ctx):
|
|
voice = get(client.voice_clients, guild=ctx.guild)
|
|
|
|
if not voice.is_playing():
|
|
voice.resume()
|
|
await ctx.send('-_-')
|
|
|
|
|
|
@client.command()
|
|
async def pause(ctx):
|
|
voice = get(client.voice_clients, guild=ctx.guild)
|
|
|
|
if voice.is_playing():
|
|
voice.pause()
|
|
await ctx.send('Pausa3')
|
|
|
|
|
|
@client.command()
|
|
async def stop(ctx):
|
|
voice = get(client.voice_clients, guild=ctx.guild)
|
|
|
|
if voice.is_playing():
|
|
voice.stop()
|
|
|
|
@client.command()
|
|
async def disconnect(ctx):
|
|
channel = ctx.message.author.voice.channel
|
|
await ctx.send('nv pai')
|
|
await ctx.voice_client.disconnect()
|
|
|
|
client.run(inf0.dc_data)
|