Sécuriter sur Music et message de démmarage
This commit is contained in:
parent
719d3984a1
commit
5b8be19e8a
2 changed files with 76 additions and 39 deletions
39
Music.py
39
Music.py
|
@ -63,6 +63,7 @@ class VoiceState:
|
|||
await self.bot.send_message(self.current.channel, ' Joue maintenant ' + str(self.current))
|
||||
self.current.player.start()
|
||||
await self.play_next_song.wait()
|
||||
|
||||
class Music:
|
||||
"""Commandes de musique.
|
||||
"""
|
||||
|
@ -92,6 +93,12 @@ class Music:
|
|||
except:
|
||||
pass
|
||||
|
||||
def is_listening(self, user_channel):
|
||||
for bot_channel in self.bot.voice_clients:
|
||||
if bot_channel.channel == user_channel:
|
||||
return True
|
||||
return False
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def join(self, ctx, *, channel : discord.Channel):
|
||||
"""Rejoins le channel vocal. Ne fonctionne que si l'utilisateur est deja dans un channel.
|
||||
|
@ -155,28 +162,49 @@ class Music:
|
|||
await self.bot.say('La musique ' + str(entry)+" a été mise en queue")
|
||||
await state.songs.put(entry)
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def listening(self, ctx):
|
||||
voice_channel_id = ctx.message.author.voice_channel
|
||||
if self.is_listening(voice_channel_id) == True:
|
||||
await self.bot.say("Vous écouter le bot !")
|
||||
|
||||
elif self.is_listening(voice_channel_id) == False:
|
||||
await self.bot.say("Vous n'écouter pas le bot !")
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def volume(self, ctx, value : int):
|
||||
"""Définie le volume du bot."""
|
||||
|
||||
voice_channel_id = ctx.message.author.voice_channel
|
||||
if self.is_listening(voice_channel_id) == True:
|
||||
state = self.get_voice_state(ctx.message.server)
|
||||
if state.is_playing():
|
||||
player = state.player
|
||||
player.volume = value / 100
|
||||
await self.bot.say('Volume mit à {:.0%}'.format(player.volume))
|
||||
|
||||
elif self.is_listening(voice_channel_id) == False:
|
||||
await self.bot.say("Désoler mais vous n'écouter pas le bot !")
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def resume(self, ctx):
|
||||
"""Relance la misique jouée."""
|
||||
voice_channel_id = ctx.message.author.voice_channel
|
||||
if self.is_listening(voice_channel_id) == True:
|
||||
state = self.get_voice_state(ctx.message.server)
|
||||
if state.is_playing():
|
||||
player = state.player
|
||||
player.resume()
|
||||
|
||||
elif self.is_listening(voice_channel_id) == False:
|
||||
await self.bot.say("Désoler mais vous n'écouter pas le bot !")
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def stop(self, ctx):
|
||||
"""Arrete la musique jouée et quitte le channel.
|
||||
Cela vide aussi la queue.
|
||||
"""
|
||||
voice_channel_id = ctx.message.author.voice_channel
|
||||
if self.is_listening(voice_channel_id) == True:
|
||||
server = ctx.message.server
|
||||
state = self.get_voice_state(server)
|
||||
|
||||
|
@ -192,12 +220,16 @@ class Music:
|
|||
except:
|
||||
pass
|
||||
|
||||
elif self.is_listening(voice_channel_id) == False:
|
||||
await self.bot.say("Désoler mais vous n'écouter pas le bot !")
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def skip(self, ctx):
|
||||
"""Vote pour passer la chanson en cours.
|
||||
Il faut trois votes pour passer la chanson.
|
||||
"""
|
||||
|
||||
voice_channel_id = ctx.message.author.voice_channel
|
||||
if self.is_listening(voice_channel_id) == True:
|
||||
state = self.get_voice_state(ctx.message.server)
|
||||
if not state.is_playing():
|
||||
await self.bot.say("Aucune chanson n'est jouée actuellement...")
|
||||
|
@ -218,6 +250,9 @@ class Music:
|
|||
else:
|
||||
await self.bot.say('Vous avez deja voté pour passer cette chanson.')
|
||||
|
||||
elif self.is_listening(voice_channel_id) == False:
|
||||
await self.bot.say("Désoler mais vous n'écouter pas le bot !")
|
||||
|
||||
@commands.command(pass_context=True, no_pm=True)
|
||||
async def playing(self, ctx):
|
||||
"""Montre des informations sur la chanson jouée."""
|
||||
|
|
2
bot.py
2
bot.py
|
@ -41,6 +41,8 @@ async def on_ready():
|
|||
bot.load_extension("Music")
|
||||
|
||||
print("FTW's Bot operationelle")
|
||||
channel = bot.get_channel("389209382388498445")
|
||||
await bot.send_message(channel, "FTW's Bot operationelle")
|
||||
|
||||
@bot.command(pass_context = True)
|
||||
async def load(ctx, ext):
|
||||
|
|
Reference in a new issue