Ajout de la commande .appel, pour faciliter l'appel
This commit is contained in:
parent
74a316262d
commit
e5ecf75176
1 changed files with 35 additions and 1 deletions
|
@ -213,3 +213,37 @@ class Commands(commands.Cog):
|
|||
for i in affichage:
|
||||
message = message + f", {tuple[i]} {time[i]}"
|
||||
return message[2:]
|
||||
|
||||
@commands.command()
|
||||
@commands.has_any_role("Professeur", "professeur", "Prof", "prof")
|
||||
async def appel(self, ctx, *, voice_channel: int = None):
|
||||
voice_channels = []
|
||||
voice_channels.extend(ctx.guild.voice_channels)
|
||||
if voice_channel:
|
||||
voice_channels = [self.bot.get_channel(voice_channel)]
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
if len(voice_channels) > 0:
|
||||
embed = discord.Embed(title = "Réagissez à ce message avec ✋ pour signaler votre présence." ,description = f"(attention, je réagis aussi) — Professeur : {ctx.author.mention}")
|
||||
for channel in voice_channels:
|
||||
prof = []
|
||||
for role in ["Professeur", "professeur", "Prof", "prof"]:
|
||||
role = discord.utils.get(ctx.guild.roles, name=role)
|
||||
for user in channel.members:
|
||||
if role in user.roles and user not in prof:
|
||||
prof.append(user)
|
||||
eleve = channel.members
|
||||
for user in channel.members:
|
||||
if user in prof:
|
||||
eleve.remove(user)
|
||||
value = f"**{len(channel.members)}** personne{'s' if len(channel.members)>1 else ''} connectée{'s' if len(channel.members)>1 else ''}.\nDont {len(eleve)} élève{'s' if len(eleve)>1 else ''} et {len(prof)} professeur{'s' if len(prof)>1 else ''}."
|
||||
embed.add_field(name = f"🔊 {channel.name}", value = value, inline = False)
|
||||
message = await ctx.send(embed = embed)
|
||||
else:
|
||||
message = await ctx.send("Aucun salon vocal dans ce serveur, réagissez à ce message avec ✋ pour signaler votre présence (attention, je réagis aussi).")
|
||||
await message.add_reaction(emoji = '✋')
|
||||
@appel.error
|
||||
async def appel_error(self, ctx, error):
|
||||
if isinstance(error, commands.CheckFailure):
|
||||
await ctx.send("Tu n'as pas la permission de faire cette commande, demande à un professeur.")
|
||||
else:
|
||||
await ctx.send("Une erreur est survenue, syntaxe: `.appel [ID salon vocal]`.")
|
Reference in a new issue