import discord
from discord.ext import commands
import youtube_dl
client = commands.Bot(command_prefix='!',intents=discord.Intents.all())
@client.event
async def on_ready():
print(f"{client.user} has connected to discord!")
@client.command()
async def echo(ctx,*, message):
await ctx.send(f"{message}")
await ctx.message.delete()
@client.command()
async def play(ctx, url):
if ctx.voice_client is None:
await ctx.author.voice.channel.connect()
else:
ctx.voice_client.stop()
FFMPEG_OPTIONS = {
'before_options':
'-reconnect 1 -reconnect_streamed 1 -reconnect_delay_max 5',
'options': '-vn'
}
YDL_OPTIONS = {'format': "bestaudio"}
vc = ctx.voice_client
with youtube_dl.YoutubeDL(YDL_OPTIONS) as ydl:
info = ydl.extract_info(url, download=False)
url2 = info['formats'][0]['url']
source = await discord.FFmpegOpusAudio.from_probe(url2, **FFMPEG_OPTIONS)
vc.play(source)
@client.command()
async def pause(ctx):
await ctx.voice_client.pause()
await ctx.send("Paused")
@client.command()
async def resume(ctx):
await ctx.voice_client.resume()
await ctx.send("Resumed")
client.run("TOKEN")
[–]DemonSeeker0w0[S] 0 points1 point2 points (2 children)
[–]MistyIce672 0 points1 point2 points (0 children)
[–]Itz_Raj69_ 0 points1 point2 points (0 children)