commit
b115dc2202
5 changed files with 231 additions and 61 deletions
141
Channeller.py
Normal file
141
Channeller.py
Normal file
|
@ -0,0 +1,141 @@
|
||||||
|
import json
|
||||||
|
import discord
|
||||||
|
from discord.ext import commands
|
||||||
|
|
||||||
|
class Channeller:
|
||||||
|
def __init__(self, bot):
|
||||||
|
self.bot = bot
|
||||||
|
with open('config.json') as json_data_file:
|
||||||
|
parameter = json.load(json_data_file)
|
||||||
|
|
||||||
|
self.owner = parameter['Perms']['Admin']
|
||||||
|
|
||||||
|
self.server = self.bot.get_server("177396472294277120")
|
||||||
|
self.ow_role = discord.utils.get(self.server.roles, name="🔫 Overwatch")
|
||||||
|
|
||||||
|
ow_chan = dict()
|
||||||
|
pv_chan = dict()
|
||||||
|
|
||||||
|
"""await def __unload(self):
|
||||||
|
print("Channeller off")
|
||||||
|
for c in self.ow_chan.values():
|
||||||
|
await self.bot.delete_channel(c)"""
|
||||||
|
|
||||||
|
def is_owner(self, id):
|
||||||
|
if id in self.owner:
|
||||||
|
return True
|
||||||
|
return False
|
||||||
|
|
||||||
|
#Groupe de commande du Channeller
|
||||||
|
@commands.group(pass_context=True)
|
||||||
|
async def channeller(self, ctx):
|
||||||
|
if ctx.invoked_subcommand is None:
|
||||||
|
await ctx.invoke(self.help)
|
||||||
|
|
||||||
|
#Le help
|
||||||
|
@channeller.command(pass_context=True)
|
||||||
|
async def help(self, ctx):
|
||||||
|
embed=discord.Embed(title="Channeller", description="Aide", color=0xff0000)
|
||||||
|
embed.set_thumbnail(url="https://i.imgur.com/F7M1e6s.png")
|
||||||
|
embed.add_field(name="jeux", value="Crée un channel vocal pour jouer !", inline=True)
|
||||||
|
embed.add_field(name="private", value="Crée un channel vocal privée", inline=True)
|
||||||
|
embed.add_field(name="publique", value="Crée un channel vocal publique", inline=True)
|
||||||
|
await self.bot.say(embed=embed)
|
||||||
|
|
||||||
|
#Crée un Channel jeux
|
||||||
|
@channeller.command(pass_context=True)
|
||||||
|
async def jeux(self, ctx, jeux):
|
||||||
|
|
||||||
|
help=discord.Embed(title="Channeller jeux", description="Aide", color=0xff0000)
|
||||||
|
help.set_thumbnail(url="https://i.imgur.com/F7M1e6s.png")
|
||||||
|
help.add_field(name="overwatch", value="Crée un channel vocal pour jouer !", inline=True)
|
||||||
|
help.add_field(name="fortinte", value="Crée un channel vocal privée", inline=True) #TODO: Changer "fortninte",et mettre fortnite
|
||||||
|
help.add_field(name="factorio", value="Crée un channel vocal publique", inline=True)
|
||||||
|
help.add_field(name="minecraft", value="Crée un channel", inline=True)
|
||||||
|
help.add_field(name="minecrafticka", value="Crée un channel vocal", inline=True)
|
||||||
|
|
||||||
|
if jeux == "list":
|
||||||
|
await self.bot.say(embed=help)
|
||||||
|
|
||||||
|
elif jeux == None:
|
||||||
|
await self.bot.say(embed=help)
|
||||||
|
|
||||||
|
elif jeux == "overwatch":
|
||||||
|
if self.ow_role in ctx.message.author.roles:
|
||||||
|
everyone_perms = discord.PermissionOverwrite(connect=False)
|
||||||
|
ow_perms = discord.PermissionOverwrite(connect=True)
|
||||||
|
|
||||||
|
everyone = discord.ChannelPermissions(target=self.server.default_role, overwrite=everyone_perms)
|
||||||
|
ow = discord.ChannelPermissions(target=self.ow_role, overwrite=ow_perms)
|
||||||
|
|
||||||
|
name = "Overwatch "+str(len(self.ow_chan)+1)
|
||||||
|
self.ow_chan[name] = await self.bot.create_channel(self.server, name, everyone, ow, type=discord.ChannelType.voice)
|
||||||
|
embed=discord.Embed(title="Channeller jeux", description="Info", color=0xff0000)
|
||||||
|
embed.set_thumbnail(url="https://i.imgur.com/F7M1e6s.png")
|
||||||
|
embed.add_field(name="jeux overwatch", value="Channel créé ! Déplacement automatique...", inline=True)
|
||||||
|
await self.bot.say(embed=embed)
|
||||||
|
print("Channel "+str(name)+" créé par: "+str(ctx.message.author))
|
||||||
|
await self.bot.move_member(ctx.message.author, self.ow_chan[name])
|
||||||
|
|
||||||
|
else:
|
||||||
|
await self.bot.say("No")
|
||||||
|
embed=discord.Embed(title="Channeller jeux", description="Erreur", color=0xff0000)
|
||||||
|
embed.set_thumbnail(url="https://i.imgur.com/F7M1e6s.png")
|
||||||
|
embed.add_field(name="jeux overwatch", value="Désolé mais vous n'avez pas le grade du jeu corespondant !", inline=True)
|
||||||
|
await self.bot.say(embed=embed)
|
||||||
|
print("Refus de création d'un channel Overwatch, "+str(ctx.message.author)+" ne possède pas le grade")
|
||||||
|
|
||||||
|
else:
|
||||||
|
await self.bot.say(embed=help)
|
||||||
|
|
||||||
|
@channeller.command(pass_context=True)
|
||||||
|
async def private(self, ctx, nom, perso):
|
||||||
|
|
||||||
|
if nom in self.pv_chan.values():
|
||||||
|
print("nom deja existant !")
|
||||||
|
|
||||||
|
else:
|
||||||
|
everyone_perms = discord.PermissionOverwrite(connect=False)
|
||||||
|
pv_perms = discord.PermissionOverwrite(connect=True)
|
||||||
|
|
||||||
|
everyone = discord.ChannelPermissions(target=self.server.default_role, overwrite=everyone_perms)
|
||||||
|
pv = discord.ChannelPermissions(target=ctx.message.author, overwrite=pv_perms)
|
||||||
|
|
||||||
|
self.pv_chan[nom] = await self.bot.create_channel(self.server, nom, everyone, pv, type=discord.ChannelType.voice)
|
||||||
|
|
||||||
|
"""for player in perso:
|
||||||
|
test"""
|
||||||
|
print(perso)
|
||||||
|
|
||||||
|
embed=discord.Embed(title="Channeller priver", description="Info", color=0xff0000)
|
||||||
|
embed.set_thumbnail(url="https://i.imgur.com/F7M1e6s.png")
|
||||||
|
embed.add_field(name="Priver", value="Channel créé ! Déplacement automatique...", inline=True)
|
||||||
|
await self.bot.say(embed=embed)
|
||||||
|
print("Channel "+str(nom)+" créé par: "+str(ctx.message.author))
|
||||||
|
await self.bot.move_member(ctx.message.author, self.pv_chan[nom])
|
||||||
|
|
||||||
|
"""@channeller.command(pass_contexte=True)
|
||||||
|
async def delete(self):
|
||||||
|
for n in range(0, self.ow_num):
|
||||||
|
await self.bot.delete_channel(self.ow_chan["ow_"+str(n+1)])
|
||||||
|
self.ow_chan = dict()"""
|
||||||
|
|
||||||
|
async def on_voice_state_update(self, x, y):
|
||||||
|
#OW clear
|
||||||
|
for c in self.ow_chan.values():
|
||||||
|
self.ow_chan[str(c)] = self.bot.get_channel(c.id)
|
||||||
|
if len(self.ow_chan[str(c)].voice_members) == 0:
|
||||||
|
await self.bot.delete_channel(c)
|
||||||
|
del self.ow_chan[str(c)]
|
||||||
|
|
||||||
|
#PV clear
|
||||||
|
for c in self.pv_chan.values():
|
||||||
|
self.pv_chan[str(c)] = self.bot.get_channel(c.id)
|
||||||
|
if len(self.pv_chan[str(c)].voice_members) == 0:
|
||||||
|
await self.bot.delete_channel(c)
|
||||||
|
del self.pv_chan[str(c)]
|
||||||
|
|
||||||
|
|
||||||
|
def setup(bot):
|
||||||
|
bot.add_cog(Channeller(bot))
|
||||||
|
print("Channeller chargé")
|
80
Garou.py
80
Garou.py
|
@ -3,7 +3,6 @@ import discord
|
||||||
import random
|
import random
|
||||||
from random import randint
|
from random import randint
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
#from threading import Thread
|
|
||||||
|
|
||||||
|
|
||||||
class Garou:
|
class Garou:
|
||||||
|
@ -13,15 +12,16 @@ class Garou:
|
||||||
|
|
||||||
with open('config.json') as json_data_file:
|
with open('config.json') as json_data_file:
|
||||||
self.parameter = json.load(json_data_file)
|
self.parameter = json.load(json_data_file)
|
||||||
|
|
||||||
self.owner = self.parameter['Perms']['Admin']
|
self.owner = self.parameter['Perms']['Admin']
|
||||||
|
|
||||||
#Truc utile
|
self.server = self.bot.get_server("177396472294277120") #On defini le serveur
|
||||||
self.server = self.bot.get_server("177396472294277120")
|
|
||||||
self.garou_role = discord.utils.get(self.server.roles, name="Garou")
|
|
||||||
self.mort_role = discord.utils.get(self.server.roles, name="Morts")
|
|
||||||
|
|
||||||
#Get des channels.
|
#Get des roles :
|
||||||
|
self.garou_role = discord.utils.get(self.server.roles, name="🐺 Garou")
|
||||||
|
self.mort_role = discord.utils.get(self.server.roles, name="☠️ Morts")
|
||||||
|
|
||||||
|
#Get des channels :
|
||||||
self.forum_channel = self.bot.get_channel("402067902469242900")
|
self.forum_channel = self.bot.get_channel("402067902469242900")
|
||||||
self.Garou_channel = self.bot.get_channel("403500093380100106")
|
self.Garou_channel = self.bot.get_channel("403500093380100106")
|
||||||
self.soeur_channel = self.bot.get_channel("403518380017057792")
|
self.soeur_channel = self.bot.get_channel("403518380017057792")
|
||||||
|
@ -39,7 +39,7 @@ class Garou:
|
||||||
self.perms_nuit_Garou.read_message_history = False
|
self.perms_nuit_Garou.read_message_history = False
|
||||||
self.perms_nuit_Garou.send_messages = True
|
self.perms_nuit_Garou.send_messages = True
|
||||||
self.perms_nuit_Garou.read_messages = True
|
self.perms_nuit_Garou.read_messages = True
|
||||||
|
|
||||||
self.perms_nuit_soeur = discord.PermissionOverwrite()
|
self.perms_nuit_soeur = discord.PermissionOverwrite()
|
||||||
self.perms_nuit_soeur.read_message_history = False
|
self.perms_nuit_soeur.read_message_history = False
|
||||||
self.perms_nuit_soeur.send_messages = True
|
self.perms_nuit_soeur.send_messages = True
|
||||||
|
@ -56,12 +56,15 @@ class Garou:
|
||||||
self.perms_jour_Garou.read_message_history = False
|
self.perms_jour_Garou.read_message_history = False
|
||||||
self.perms_jour_Garou.send_messages = False
|
self.perms_jour_Garou.send_messages = False
|
||||||
self.perms_jour_Garou.read_messages = True
|
self.perms_jour_Garou.read_messages = True
|
||||||
|
|
||||||
self.perms_jour_soeur = discord.PermissionOverwrite()
|
self.perms_jour_soeur = discord.PermissionOverwrite()
|
||||||
self.perms_jour_soeur.read_message_history = False
|
self.perms_jour_soeur.read_message_history = False
|
||||||
self.perms_jour_soeur.send_messages = False
|
self.perms_jour_soeur.send_messages = False
|
||||||
self.perms_jour_soeur.read_messages = True
|
self.perms_jour_soeur.read_messages = True
|
||||||
|
|
||||||
|
"""async def __unload(self):
|
||||||
|
await self.end()"""
|
||||||
|
|
||||||
|
|
||||||
#Variables de base
|
#Variables de base
|
||||||
game = 0 #Dit si une partie est en cours et a quelle stade elle en est
|
game = 0 #Dit si une partie est en cours et a quelle stade elle en est
|
||||||
|
@ -397,7 +400,7 @@ class Garou:
|
||||||
|
|
||||||
#Routine a chaque nuit
|
#Routine a chaque nuit
|
||||||
async def night_start(self):
|
async def night_start(self):
|
||||||
|
|
||||||
#Envoie du message de nuit
|
#Envoie du message de nuit
|
||||||
await self.bot.send_message(self.forum_channel, embed=self.soir)
|
await self.bot.send_message(self.forum_channel, embed=self.soir)
|
||||||
await self.bot.change_presence(game=discord.Game(name="LG: c'est la nuit sur Thiercelieu"))
|
await self.bot.change_presence(game=discord.Game(name="LG: c'est la nuit sur Thiercelieu"))
|
||||||
|
@ -424,7 +427,7 @@ class Garou:
|
||||||
|
|
||||||
self.SA = 1
|
self.SA = 1
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if "CU" in self.def_joueurs.values():
|
if "CU" in self.def_joueurs.values():
|
||||||
if self.CU == 0:
|
if self.CU == 0:
|
||||||
#Tour de Cupidon
|
#Tour de Cupidon
|
||||||
|
@ -442,10 +445,10 @@ class Garou:
|
||||||
#Amoureux se rencontre
|
#Amoureux se rencontre
|
||||||
print("Amoureux se rencontre")
|
print("Amoureux se rencontre")
|
||||||
await self.bot.change_presence(game=discord.Game(name="LG: c'est la nuit, tour des amoureux"))
|
await self.bot.change_presence(game=discord.Game(name="LG: c'est la nuit, tour des amoureux"))
|
||||||
|
|
||||||
self.CU == 3
|
self.CU == 3
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if "SE" in self.def_joueurs.values():
|
if "SE" in self.def_joueurs.values():
|
||||||
if self.SE == 0:
|
if self.SE == 0:
|
||||||
#Tour des Sœur
|
#Tour des Sœur
|
||||||
|
@ -534,10 +537,17 @@ class Garou:
|
||||||
loup=discord.Embed(title="Garou", description="Nuit", color=0xff0000)
|
loup=discord.Embed(title="Garou", description="Nuit", color=0xff0000)
|
||||||
loup.set_thumbnail(url="https://i.imgur.com/XLPDenM.png")
|
loup.set_thumbnail(url="https://i.imgur.com/XLPDenM.png")
|
||||||
loup.add_field(name="Vote", value="Les votes sont ouvert pour chosir qui tuer ce soir !", inline=False)
|
loup.add_field(name="Vote", value="Les votes sont ouvert pour chosir qui tuer ce soir !", inline=False)
|
||||||
loup.add_field(name="Victime", value="")
|
|
||||||
|
|
||||||
|
|
||||||
self.LG = 1
|
self.LG = 1
|
||||||
|
|
||||||
|
elif self.LG == 2:
|
||||||
|
print("Fin du vote des Loups-Garou")
|
||||||
|
loup=discord.Embed(title="Garou", description="Nuit", color=0xff0000)
|
||||||
|
loup.set_thumbnail(url="https://i.imgur.com/XLPDenM.png")
|
||||||
|
loup.add_field(name="Vote", value="Les votes sont fini !", inline=False)
|
||||||
|
loup.add_field(name="Vote", value="Vous avez choisi "+str(self.LG_victime)+" !", inline=False)
|
||||||
|
|
||||||
|
self.LG = 3
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if "GML" in self.def_joueurs.values():
|
if "GML" in self.def_joueurs.values():
|
||||||
|
@ -552,7 +562,7 @@ class Garou:
|
||||||
|
|
||||||
self.GML = 1
|
self.GML = 1
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if "SO" in self.def_joueurs.values():
|
if "SO" in self.def_joueurs.values():
|
||||||
if self.SO == 0:
|
if self.SO == 0:
|
||||||
#Tour de la Sorcière
|
#Tour de la Sorcière
|
||||||
|
@ -565,7 +575,7 @@ class Garou:
|
||||||
|
|
||||||
self.SO = 1
|
self.SO = 1
|
||||||
return None
|
return None
|
||||||
|
|
||||||
if "AS" in self.def_joueurs.values():
|
if "AS" in self.def_joueurs.values():
|
||||||
if self.AS == 0:
|
if self.AS == 0:
|
||||||
#Tour de l'Assassin
|
#Tour de l'Assassin
|
||||||
|
@ -609,11 +619,11 @@ class Garou:
|
||||||
elif self.jour == 2:
|
elif self.jour == 2:
|
||||||
#if
|
#if
|
||||||
return None
|
return None
|
||||||
|
|
||||||
#Gestion des morts
|
#Gestion des morts
|
||||||
if night_death == 0:
|
if night_death == 0:
|
||||||
await self.death()
|
await self.death()
|
||||||
|
|
||||||
self.night_death = 0
|
self.night_death = 0
|
||||||
|
|
||||||
#Action de fin de nuit
|
#Action de fin de nuit
|
||||||
|
@ -641,7 +651,7 @@ class Garou:
|
||||||
for j, r in self.def_joueurs:
|
for j, r in self.def_joueurs:
|
||||||
if r != "Mort":
|
if r != "Mort":
|
||||||
await self.bot.server_voice_state(j, mute=False, deafen=False)
|
await self.bot.server_voice_state(j, mute=False, deafen=False)
|
||||||
|
|
||||||
async def death(self):
|
async def death(self):
|
||||||
if self.morts != []:
|
if self.morts != []:
|
||||||
mort=discord.Embed(title="Garou", description="Nuit", color=0xff0000)
|
mort=discord.Embed(title="Garou", description="Nuit", color=0xff0000)
|
||||||
|
@ -654,23 +664,23 @@ class Garou:
|
||||||
mort.add_field(name="Morts", value="@"+str(j)+" est mort(e) ce soir ! \nCetait un(e) "+str(self.get_role_name(role))+" !", inline=False)
|
mort.add_field(name="Morts", value="@"+str(j)+" est mort(e) ce soir ! \nCetait un(e) "+str(self.get_role_name(role))+" !", inline=False)
|
||||||
await self.bot.send_message(self.forum_channel, embed=mort)
|
await self.bot.send_message(self.forum_channel, embed=mort)
|
||||||
self.morts = list()
|
self.morts = list()
|
||||||
|
|
||||||
#Gestion du retour
|
#Gestion du retour
|
||||||
if self.jour == 1:
|
if self.jour == 1:
|
||||||
if self.day_death == 0:
|
if self.day_death == 0:
|
||||||
self.day_death = 1
|
self.day_death = 1
|
||||||
await self.day_start()
|
await self.day_start()
|
||||||
|
|
||||||
elif self.jour == 2:
|
elif self.jour == 2:
|
||||||
if self.night_death == 0:
|
if self.night_death == 0:
|
||||||
self.night_death = 1
|
self.night_death = 1
|
||||||
await self.day_start()
|
await self.day_start()
|
||||||
|
|
||||||
elif self.jour == 0:
|
elif self.jour == 0:
|
||||||
if self.night_death == 0:
|
if self.night_death == 0:
|
||||||
self.night_death = 1
|
self.night_death = 1
|
||||||
await self.day_start()
|
await self.day_start()
|
||||||
|
|
||||||
return True
|
return True
|
||||||
|
|
||||||
|
|
||||||
|
@ -702,7 +712,7 @@ class Garou:
|
||||||
|
|
||||||
#Reset des variables
|
#Reset des variables
|
||||||
print("Reset des variables")
|
print("Reset des variables")
|
||||||
|
|
||||||
|
|
||||||
#Marche pas :/
|
#Marche pas :/
|
||||||
#await self.bot.change_presence(self.save_game) #Reset du statu
|
#await self.bot.change_presence(self.save_game) #Reset du statu
|
||||||
|
@ -736,7 +746,7 @@ class Garou:
|
||||||
embed.add_field(name="Début de partie", value="Une partie a été lancer par: "+str(ctx.message.author)+" ! \nPour rejoindre, taper la commande: ```lg join```", inline=False)
|
embed.add_field(name="Début de partie", value="Une partie a été lancer par: "+str(ctx.message.author)+" ! \nPour rejoindre, taper la commande: ```lg join```", inline=False)
|
||||||
await self.bot.say(embed=embed)
|
await self.bot.say(embed=embed)
|
||||||
self.research = 1
|
self.research = 1
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
#Commande pour rejoindre la partie
|
#Commande pour rejoindre la partie
|
||||||
|
@ -800,7 +810,7 @@ class Garou:
|
||||||
else:
|
else:
|
||||||
self.game=2 #On dit que les joueurs sont defini
|
self.game=2 #On dit que les joueurs sont defini
|
||||||
self.num_joueurs=len(self.list_joueurs) #On defini combien de joueurs en tout
|
self.num_joueurs=len(self.list_joueurs) #On defini combien de joueurs en tout
|
||||||
|
|
||||||
print("Commande lg play lancer par: "+str(ctx.message.author)) #On log
|
print("Commande lg play lancer par: "+str(ctx.message.author)) #On log
|
||||||
await self.bot.change_presence(game=discord.Game(name='LG: definition des roles..."'))
|
await self.bot.change_presence(game=discord.Game(name='LG: definition des roles..."'))
|
||||||
|
|
||||||
|
@ -818,7 +828,7 @@ class Garou:
|
||||||
self.r = self.r+2
|
self.r = self.r+2
|
||||||
|
|
||||||
self.def_joueurs[target] = self.roles[r] #Ajoute dans le dico le joueur et assigne son role grace au chiffre random
|
self.def_joueurs[target] = self.roles[r] #Ajoute dans le dico le joueur et assigne son role grace au chiffre random
|
||||||
|
|
||||||
|
|
||||||
#Envoie du message de role
|
#Envoie du message de role
|
||||||
embed = self.intro(self.roles[r])
|
embed = self.intro(self.roles[r])
|
||||||
|
@ -843,13 +853,13 @@ class Garou:
|
||||||
|
|
||||||
#Gestion des permissions de base
|
#Gestion des permissions de base
|
||||||
await self.bot.edit_channel_permissions(self.forum_channel, self.garou_role, self.perms_nuit_forum)
|
await self.bot.edit_channel_permissions(self.forum_channel, self.garou_role, self.perms_nuit_forum)
|
||||||
|
|
||||||
#Envoie du message du début
|
#Envoie du message du début
|
||||||
embed=discord.Embed(title="Garou", description="Démarrage", color=0xff0000)
|
embed=discord.Embed(title="Garou", description="Démarrage", color=0xff0000)
|
||||||
embed.set_thumbnail(url="https://i.imgur.com/XLPDenM.png")
|
embed.set_thumbnail(url="https://i.imgur.com/XLPDenM.png")
|
||||||
embed.add_field(name="Début de partie", value="Bienvenue dans la partie de Garou ! \nIl y a "+str(self.num_joueurs)+" habitants a Thiercelieu pour le moment. \nBonne chance !", inline=False)
|
embed.add_field(name="Début de partie", value="Bienvenue dans la partie de Garou ! \nIl y a "+str(self.num_joueurs)+" habitants a Thiercelieu pour le moment. \nBonne chance !", inline=False)
|
||||||
await self.bot.send_message(self.forum_channel, embed=embed)
|
await self.bot.send_message(self.forum_channel, embed=embed)
|
||||||
|
|
||||||
#On commence la nuit
|
#On commence la nuit
|
||||||
await self.night_start()
|
await self.night_start()
|
||||||
|
|
||||||
|
@ -862,8 +872,8 @@ class Garou:
|
||||||
self.morts.append(ctx.message.author) #Pour le test
|
self.morts.append(ctx.message.author) #Pour le test
|
||||||
|
|
||||||
await self.death()
|
await self.death()
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
@lg.command(pass_context=True)
|
@lg.command(pass_context=True)
|
||||||
async def vote(self, ctx):
|
async def vote(self, ctx):
|
||||||
|
@ -887,11 +897,11 @@ class Garou:
|
||||||
|
|
||||||
elif r == "LG":
|
elif r == "LG":
|
||||||
if self.LG == 1:
|
if self.LG == 1:
|
||||||
#Vote des loup Garous
|
|
||||||
print("Vote des loups-garou")
|
print("Vote des loups-garou")
|
||||||
|
|
||||||
#Faut faire le system de vote et aprés cela
|
if valuraupif == True:
|
||||||
#self.LG = 2
|
self.LG = 2
|
||||||
|
await self.night_start()
|
||||||
|
|
||||||
|
|
||||||
elif r == "VY":
|
elif r == "VY":
|
||||||
|
|
65
Music.py
65
Music.py
|
@ -68,11 +68,11 @@ class VoiceState:
|
||||||
await self.bot.send_message(self.current.channel, embed=embed)
|
await self.bot.send_message(self.current.channel, embed=embed)
|
||||||
self.current.player.start()
|
self.current.player.start()
|
||||||
await self.play_next_song.wait()
|
await self.play_next_song.wait()
|
||||||
|
|
||||||
|
|
||||||
class Musique:
|
class Musique:
|
||||||
"""Commandes de musique.
|
#Commandes de musique.
|
||||||
"""
|
|
||||||
def __init__(self, bot):
|
def __init__(self, bot):
|
||||||
self.bot = bot
|
self.bot = bot
|
||||||
self.voice_states = {}
|
self.voice_states = {}
|
||||||
|
@ -133,14 +133,14 @@ class Musique:
|
||||||
embed.add_field(name="skip", value="Passer la musique", inline=True)
|
embed.add_field(name="skip", value="Passer la musique", inline=True)
|
||||||
embed.add_field(name="stop", value="Arrêter la musique", inline=True)
|
embed.add_field(name="stop", value="Arrêter la musique", inline=True)
|
||||||
embed.add_field(name="summon", value="Faire apparaître le bot", inline=True)
|
embed.add_field(name="summon", value="Faire apparaître le bot", inline=True)
|
||||||
embed.add_field(name="volume", value="Définir le volume de la musique", inline=True)
|
#embed.add_field(name="volume", value="Définir le volume de la musique", inline=True)
|
||||||
await self.bot.say(embed=embed)
|
await self.bot.say(embed=embed)
|
||||||
|
|
||||||
#Permmet de faire connecter vocalement le bot
|
#Permmet de faire connecter vocalement le bot
|
||||||
@music.command(pass_context=True, no_pm=True)
|
@music.command(pass_context=True, no_pm=True)
|
||||||
async def summon(self, ctx):
|
async def summon(self, ctx):
|
||||||
"""Invoque le bot dans le channel vocal.
|
#Invoque le bot dans le channel vocal.
|
||||||
Ne fonctionne que si l'utilisateur est déja dans un channel."""
|
#Ne fonctionne que si l'utilisateur est déja dans un channel.
|
||||||
summoned_channel = ctx.message.author.voice_channel
|
summoned_channel = ctx.message.author.voice_channel
|
||||||
if summoned_channel is None:
|
if summoned_channel is None:
|
||||||
print("Commande musique summon lancée par: "+str(ctx.message.author)+" refuser car il n'est pas dans un channel vocal")
|
print("Commande musique summon lancée par: "+str(ctx.message.author)+" refuser car il n'est pas dans un channel vocal")
|
||||||
|
@ -171,13 +171,12 @@ class Musique:
|
||||||
#Permet de mettre a jouer une musique
|
#Permet de mettre a jouer une musique
|
||||||
@music.command(pass_context=True, no_pm=True)
|
@music.command(pass_context=True, no_pm=True)
|
||||||
async def play(self, ctx, *, song : str):
|
async def play(self, ctx, *, song : str):
|
||||||
"""Joue une musique.
|
#Joue une musique.
|
||||||
S'il y a une musique qui joue déjà, alors elle est mise dans
|
#S'il y a une musique qui joue déjà, alors elle est mise dans
|
||||||
la queue jusqu'a la derniere musique de la queue.
|
#la queue jusqu'a la derniere musique de la queue.
|
||||||
Le bot recherche automatiquement sur youtube.
|
#Le bot recherche automatiquement sur youtube.
|
||||||
La liste des sites supportés est trouvée ici:
|
#La liste des sites supportés est trouvée ici:
|
||||||
https://rg3.github.io/youtube-dl/supportedsites.html
|
#https://rg3.github.io/youtube-dl/supportedsites.html
|
||||||
"""
|
|
||||||
state = self.get_voice_state(ctx.message.server)
|
state = self.get_voice_state(ctx.message.server)
|
||||||
opts = {
|
opts = {
|
||||||
"format":"bestaudio/worstvideo",
|
"format":"bestaudio/worstvideo",
|
||||||
|
@ -218,9 +217,9 @@ class Musique:
|
||||||
await state.songs.put(entry)
|
await state.songs.put(entry)
|
||||||
|
|
||||||
#Permmet de definit le volume
|
#Permmet de definit le volume
|
||||||
@music.command(pass_context=True, no_pm=True)
|
"""@music.command(pass_context=True, no_pm=True)
|
||||||
async def volume(self, ctx, value : int):
|
async def volume(self, ctx, value : int):
|
||||||
"""Définie le volume du bot."""
|
#Définie le volume du bot.
|
||||||
voice_channel_id = ctx.message.author.voice_channel
|
voice_channel_id = ctx.message.author.voice_channel
|
||||||
if self.is_listening(voice_channel_id) == True:
|
if self.is_listening(voice_channel_id) == True:
|
||||||
state = self.get_voice_state(ctx.message.server)
|
state = self.get_voice_state(ctx.message.server)
|
||||||
|
@ -238,9 +237,9 @@ class Musique:
|
||||||
embed=discord.Embed(title="Musique", description="Erreur", color=0x80ff00)
|
embed=discord.Embed(title="Musique", description="Erreur", color=0x80ff00)
|
||||||
embed.set_thumbnail(url="http://www.icone-png.com/png/16/15638.png")
|
embed.set_thumbnail(url="http://www.icone-png.com/png/16/15638.png")
|
||||||
embed.add_field(name="volume", value="Vous n'étes pas dans le channel vocal !", inline=True)
|
embed.add_field(name="volume", value="Vous n'étes pas dans le channel vocal !", inline=True)
|
||||||
await self.bot.say(embed=embed)
|
await self.bot.say(embed=embed)"""
|
||||||
|
|
||||||
#MEt en pause la musique
|
#Met en pause la musique
|
||||||
@music.command(pass_context=True,no_pm=True)
|
@music.command(pass_context=True,no_pm=True)
|
||||||
async def pause(self,ctx):
|
async def pause(self,ctx):
|
||||||
voice_channel_id = ctx.message.author.voice_channel
|
voice_channel_id = ctx.message.author.voice_channel
|
||||||
|
@ -283,7 +282,7 @@ class Musique:
|
||||||
embed.add_field(name="resume", value="Vous n'étes pas dans le channel vocal !", inline=True)
|
embed.add_field(name="resume", value="Vous n'étes pas dans le channel vocal !", inline=True)
|
||||||
await self.bot.say(embed=embed)
|
await self.bot.say(embed=embed)
|
||||||
|
|
||||||
async def on_voice_state_update(self,before,after):
|
"""async def on_voice_state_update(self,before,after):
|
||||||
state = self.get_voice_state(after.server)
|
state = self.get_voice_state(after.server)
|
||||||
if type(state.voice) != type(None):
|
if type(state.voice) != type(None):
|
||||||
if type(before.voice_channel) != type(None):
|
if type(before.voice_channel) != type(None):
|
||||||
|
@ -294,14 +293,30 @@ class Musique:
|
||||||
if type(after.voice_channel) != type(None):
|
if type(after.voice_channel) != type(None):
|
||||||
if len(after.voice_channel.voice_members)>=2:
|
if len(after.voice_channel.voice_members)>=2:
|
||||||
try:await self.get_resume(state.voice.channel.server)
|
try:await self.get_resume(state.voice.channel.server)
|
||||||
except:pass
|
except:pass"""
|
||||||
|
async def on_voice_state_update(self,before,after):
|
||||||
|
state = self.get_voice_state(after.server)
|
||||||
|
if type(state.voice) != type(None):
|
||||||
|
if len(state.voice.channel.voice_members)<2:
|
||||||
|
server = after.server
|
||||||
|
if state.is_playing():
|
||||||
|
player = state.player
|
||||||
|
player.stop()
|
||||||
|
print("Stop lancer, channel vide !")
|
||||||
|
|
||||||
|
try:
|
||||||
|
state.audio_player.cancel()
|
||||||
|
del self.voice_states[server.id]
|
||||||
|
await state.voice.disconnect()
|
||||||
|
except:
|
||||||
|
pass
|
||||||
|
|
||||||
#Arret la musique et fait quitter le bot
|
#Arret la musique et fait quitter le bot
|
||||||
@music.command(pass_context=True, no_pm=True)
|
@music.command(pass_context=True, no_pm=True)
|
||||||
async def stop(self, ctx):
|
async def stop(self, ctx):
|
||||||
"""Arrete la musique jouée et quitte le channel.
|
#Arrete la musique jouée et quitte le channel.
|
||||||
Cela vide aussi la queue.
|
#Cela vide aussi la queue.
|
||||||
"""
|
|
||||||
voice_channel_id = ctx.message.author.voice_channel
|
voice_channel_id = ctx.message.author.voice_channel
|
||||||
if self.is_listening(voice_channel_id) == True:
|
if self.is_listening(voice_channel_id) == True:
|
||||||
server = ctx.message.server
|
server = ctx.message.server
|
||||||
|
@ -333,9 +348,9 @@ class Musique:
|
||||||
#Permet de passer la musique en cours
|
#Permet de passer la musique en cours
|
||||||
@music.command(pass_context=True, no_pm=True)
|
@music.command(pass_context=True, no_pm=True)
|
||||||
async def skip(self, ctx):
|
async def skip(self, ctx):
|
||||||
"""Vote pour passer la chanson en cours.
|
#Vote pour passer la chanson en cours.
|
||||||
Il faut trois votes pour passer la chanson.
|
#Il faut trois votes pour passer la chanson.
|
||||||
"""
|
|
||||||
voice_channel_id = ctx.message.author.voice_channel
|
voice_channel_id = ctx.message.author.voice_channel
|
||||||
if self.is_listening(voice_channel_id) == True:
|
if self.is_listening(voice_channel_id) == True:
|
||||||
state = self.get_voice_state(ctx.message.server)
|
state = self.get_voice_state(ctx.message.server)
|
||||||
|
|
3
bot.py
3
bot.py
|
@ -34,6 +34,9 @@ async def on_ready():
|
||||||
print("Démarrage de Music")
|
print("Démarrage de Music")
|
||||||
bot.load_extension("Music")
|
bot.load_extension("Music")
|
||||||
|
|
||||||
|
print("Démarrage de Channeller")
|
||||||
|
bot.load_extension("Channeller")
|
||||||
|
|
||||||
print("FTW's Bot opérationel")
|
print("FTW's Bot opérationel")
|
||||||
embed=discord.Embed(title="Administration", description="", color=0xffff00)
|
embed=discord.Embed(title="Administration", description="", color=0xffff00)
|
||||||
embed.set_thumbnail(url="https://icon-icons.com/icons2/562/PNG/512/on-off-power-button_icon-icons.com_53938.png")
|
embed.set_thumbnail(url="https://icon-icons.com/icons2/562/PNG/512/on-off-power-button_icon-icons.com_53938.png")
|
||||||
|
|
3
run.sh
3
run.sh
|
@ -9,4 +9,5 @@ fi
|
||||||
python3.6 -m pip install --upgrade youtube_dl
|
python3.6 -m pip install --upgrade youtube_dl
|
||||||
printf "\nMise a jour terminer !\n"
|
printf "\nMise a jour terminer !\n"
|
||||||
printf "\nLancement du FTW-Bot...\n"
|
printf "\nLancement du FTW-Bot...\n"
|
||||||
python3.6 bot.py
|
python3.6 bot.py
|
||||||
|
exit
|
||||||
|
|
Reference in a new issue