1
0
Fork 0

Merge pull request #57 from flifloo/pcp

Add call command to pcp
This commit is contained in:
Ethanell 2021-02-09 09:55:44 +01:00 committed by GitHub
commit 9c508b81b0
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -1,6 +1,6 @@
import re
from discord import Member, Role
from discord import Member, Role, Embed
from discord.ext import commands
from discord.ext.commands import BadArgument
from discord_slash import cog_ext, SlashCommandOptionType, SlashContext
@ -78,6 +78,25 @@ class PCP(commands.Cog):
await ctx.send(content=f"{ctx.author.mention} {msg}")
@cog_ext.cog_subcommand(base="pcp", name="call", description="List all students present in vocal")
@guild_only()
@has_permissions(manage_messages=True)
async def pcp_call(self, ctx: SlashContext):
if not ctx.author.voice or not ctx.author.voice.channel.category:
raise BadArgument()
r = next(filter(lambda r: ctx.author.voice.channel.category.name.upper() == r.name.upper(), ctx.guild.roles),
None)
if not r:
raise BadArgument()
p = list(map(lambda s: s.display_name, filter(lambda s: s in ctx.author.voice.channel.members, r.members)))
a = list(map(lambda s: s.display_name, filter(lambda s: s not in ctx.author.voice.channel.members, r.members)))
embed = Embed(title=f"Call for {r.name}", description=f"{len(p)}/{len(r.members)}")
embed.add_field(name="\u2705 Present", value="\n".join(p) if p else "Nobody...", inline=False)
embed.add_field(name="Absent", value="\n".join(a) if a else "Nobody...", inline=False)
await ctx.send(embeds=[embed])
@cog_ext.cog_subcommand(base="pcp", subcommand_group="group", name="fix_vocal",
description="Check all text channel permissions to reapply vocal permissions")
@has_permissions(administrator=True)