Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import discord
- from discord.ext import commands
- from discord.ext.commands import Bot
- from discord.voice_client import VoiceClient
- import asyncio
- client = commands.Bot(command_prefix = '!')
- players = {}
- class ferretbotmusic():
- def __init__(self, client):
- self.client = client
- @client.command(pass_context=True, aliases=["!Join", ""])
- async def join(self ,ctx):
- channel = ctx.message.author.voice.voice_channel
- await client.join_voice_channel(channel)
- emb = discord.Embed(color=0x7289da, title=":white_check_mark: Joined! :white_check_mark: ")
- await client.say(embed = emb)
- @client.command(pass_context=True)
- async def leave(self ,ctx):
- author = ctx.message.author
- channel = author.voice_channel
- await client.join_voice_channel(channel)
- emb = discord.Embed(color=0x7289da, title=":negative_squared_cross_mark: Disconnected! :negative_squared_cross_mark: ")
- await client.say(embed = emb)
- @client.command(pass_context=True)
- async def play(self, ctx, *, song):
- opts = { 'default_search': 'auto','quiet':True, }
- voice_client = client.voice_client_in(ctx.message.server)
- player = await voice_client.create_ytdl_player(song, ytdl_options=opts)
- players[ctx.message.server.id] = player
- player.start()
- emb = discord.Embed(color=0x7289da, title='Now Playing: ' + player.title )
- await client.say(embed = emb)
- @client.command(pass_context=True)
- async def pause(self, ctx):
- id = ctx.message.server.id
- players[id].pause()
- emb = discord.Embed(color=0x7289da, title=':pause_button: Paused! :pause_button: ')
- await client.say(embed=emb)
- @client.command(pass_context=True)
- async def stop(self, ctx):
- id = ctx.message.server.id
- players[id].stop()
- emb = discord.Embed(color=0x7289da, title=':stop_button: Stopped! :stop_button: ')
- await client.say(embed=emb)
- @client.command(pass_context=True)
- async def resume(self ,ctx):
- id = ctx.message.server.id
- players[id].resume()
- emb = discord.Embed(color=0x7289da, title=':arrow_forward: Resumed! :arrow_forward: ')
- await client.say(embed=emb)
- def setup(client):
- client.add_cog(ferretbotmusic(client))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement