Skip to content

Commit

Permalink
Merge branch 'v2' of https://github.com/Devoxin/lavalink.py into v2
Browse files Browse the repository at this point in the history
  • Loading branch information
devoxin committed Mar 24, 2018
2 parents dad98d3 + a0c69cb commit ecd434d
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 1 deletion.
4 changes: 3 additions & 1 deletion examples/music.py
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,16 @@ async def find(self, ctx, *, query):

await ctx.send(embed=embed)

@commands.is_owner()
@commands.command(aliases=['dc'])
async def disconnect(self, ctx):
player = self.bot.lavalink.players.get(ctx.guild.id)

if not player.is_connected:
return await ctx.send('Not connected.')

if not ctx.author.voice or (player.is_connected and ctx.author.voice.channel.id != int(player.channel_id)):
return await ctx.send('You\'re not in my voicechannel!')

await player.disconnect()
await ctx.send('*⃣ | Disconnected.')

Expand Down
7 changes: 7 additions & 0 deletions lavalink/PlayerManager.py
Original file line number Diff line number Diff line change
Expand Up @@ -73,6 +73,13 @@ def fetch(self, key: object, default=None):
""" Retrieves the related value from the stored user data """
return self._user_data.get(key, default)

def delete(self, key: object):
""" Removes an item from the internal storage """
try:
del self._user_data[key]
except KeyError:
pass

def add(self, requester: int, track: dict):
""" Adds a track to the queue """
self.queue.append(AudioTrack().build(track, requester))
Expand Down

0 comments on commit ecd434d

Please sign in to comment.