Created
February 26, 2021 10:12
-
-
Save Kakarot-2000/c78bbab6b5e3f70bde541b72a44b2612 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
@bot.command(name='play_song', help='To play song') | |
async def play(ctx,url): | |
try : | |
server = ctx.message.guild | |
voice_channel = server.voice_client | |
async with ctx.typing(): | |
filename = await YTDLSource.from_url(url, loop=bot.loop) | |
voice_channel.play(discord.FFmpegPCMAudio(executable="ffmpeg.exe", source=filename)) | |
await ctx.send('**Now playing:** {}'.format(filename)) | |
except: | |
await ctx.send("The bot is not connected to a voice channel.") | |
@bot.command(name='pause', help='This command pauses the song') | |
async def pause(ctx): | |
voice_client = ctx.message.guild.voice_client | |
if voice_client.is_playing(): | |
await voice_client.pause() | |
else: | |
await ctx.send("The bot is not playing anything at the moment.") | |
@bot.command(name='resume', help='Resumes the song') | |
async def resume(ctx): | |
voice_client = ctx.message.guild.voice_client | |
if voice_client.is_paused(): | |
await voice_client.resume() | |
else: | |
await ctx.send("The bot was not playing anything before this. Use play_song command") | |
@bot.command(name='stop', help='Stops the song') | |
async def stop(ctx): | |
voice_client = ctx.message.guild.voice_client | |
if voice_client.is_playing(): | |
await voice_client.stop() | |
else: | |
await ctx.send("The bot is not playing anything at the moment.") | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment