[Audio] Add [p]summon (#2786)

This commit is contained in:
aikaterna 2019-06-23 22:05:01 -07:00 committed by Michael H
parent f2b7ce9546
commit 25ccc11dc4

View File

@ -3487,6 +3487,41 @@ class Audio(commands.Cog):
player.store("playing_song", None)
player.store("requester", None)
@commands.command()
@commands.guild_only()
@commands.cooldown(1, 15, discord.ext.commands.BucketType.guild)
@commands.bot_has_permissions(embed_links=True)
async def summon(self, ctx):
"""Summon the bot to a voice channel."""
dj_enabled = await self.config.guild(ctx.guild).dj_enabled()
try:
if (
not ctx.author.voice.channel.permissions_for(ctx.me).connect
or not ctx.author.voice.channel.permissions_for(ctx.me).move_members
and self._userlimit(ctx.author.voice.channel)
):
return await self._embed_msg(
ctx, _("I don't have permission to connect to your channel.")
)
if not self._player_check(ctx):
await lavalink.connect(ctx.author.voice.channel)
player = lavalink.get_player(ctx.guild.id)
player.store("connect", datetime.datetime.utcnow())
else:
player = lavalink.get_player(ctx.guild.id)
if ctx.author.voice.channel == player.channel:
return
await player.move_to(ctx.author.voice.channel)
except AttributeError:
return await self._embed_msg(ctx, _("Connect to a voice channel first."))
except IndexError:
return await self._embed_msg(
ctx, _("Connection to Lavalink has not yet been established.")
)
if dj_enabled:
if not await self._can_instaskip(ctx, ctx.author):
return await self._embed_msg(ctx, _("You need the DJ role to summon the bot."))
@commands.command()
@commands.guild_only()
@commands.bot_has_permissions(embed_links=True)