Advertisement
HexxFerret

Untitled

Jun 23rd, 2018
76
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 2.33 KB | None | 0 0
  1. import discord
  2. from discord.ext import commands
  3. from discord.ext.commands import Bot
  4. from discord.voice_client import VoiceClient
  5. import asyncio
  6.  
  7. client = commands.Bot(command_prefix = '!')
  8. players = {}
  9.  
  10.  
  11. class ferretbotmusic():
  12.     def __init__(self, client):
  13.         self.client = client
  14.  
  15.  
  16.     @client.command(pass_context=True, aliases=["!Join", ""])
  17.     async def join(self ,ctx):
  18.         channel = ctx.message.author.voice.voice_channel
  19.         await client.join_voice_channel(channel)
  20.         emb = discord.Embed(color=0x7289da, title=":white_check_mark: Joined! :white_check_mark: ")
  21.         await client.say(embed = emb)
  22.  
  23.     @client.command(pass_context=True)
  24.     async def leave(self ,ctx):
  25.         author = ctx.message.author
  26.         channel = author.voice_channel
  27.         await client.join_voice_channel(channel)
  28.         emb = discord.Embed(color=0x7289da, title=":negative_squared_cross_mark: Disconnected! :negative_squared_cross_mark: ")
  29.         await client.say(embed = emb)
  30.  
  31.     @client.command(pass_context=True)
  32.     async def play(self, ctx, *, song):
  33.         opts = { 'default_search': 'auto','quiet':True, }
  34.         voice_client = client.voice_client_in(ctx.message.server)
  35.         player = await voice_client.create_ytdl_player(song, ytdl_options=opts)
  36.         players[ctx.message.server.id] = player
  37.         player.start()
  38.         emb = discord.Embed(color=0x7289da, title='Now Playing: ' + player.title )
  39.         await client.say(embed = emb)
  40.  
  41.     @client.command(pass_context=True)
  42.     async def pause(self, ctx):
  43.         id = ctx.message.server.id
  44.         players[id].pause()
  45.         emb = discord.Embed(color=0x7289da, title=':pause_button: Paused! :pause_button: ')
  46.         await client.say(embed=emb)
  47.  
  48.     @client.command(pass_context=True)
  49.     async def stop(self, ctx):
  50.         id = ctx.message.server.id
  51.         players[id].stop()
  52.         emb = discord.Embed(color=0x7289da, title=':stop_button: Stopped! :stop_button: ')
  53.         await client.say(embed=emb)
  54.  
  55.     @client.command(pass_context=True)
  56.     async def resume(self ,ctx):
  57.         id = ctx.message.server.id
  58.         players[id].resume()
  59.         emb = discord.Embed(color=0x7289da, title=':arrow_forward: Resumed! :arrow_forward: ')
  60.         await client.say(embed=emb)
  61.  
  62.  
  63. def setup(client):
  64.     client.add_cog(ferretbotmusic(client))
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement