commit
9c508b81b0
1 changed files with 20 additions and 1 deletions
|
@ -1,6 +1,6 @@
|
||||||
import re
|
import re
|
||||||
|
|
||||||
from discord import Member, Role
|
from discord import Member, Role, Embed
|
||||||
from discord.ext import commands
|
from discord.ext import commands
|
||||||
from discord.ext.commands import BadArgument
|
from discord.ext.commands import BadArgument
|
||||||
from discord_slash import cog_ext, SlashCommandOptionType, SlashContext
|
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}")
|
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",
|
@cog_ext.cog_subcommand(base="pcp", subcommand_group="group", name="fix_vocal",
|
||||||
description="Check all text channel permissions to reapply vocal permissions")
|
description="Check all text channel permissions to reapply vocal permissions")
|
||||||
@has_permissions(administrator=True)
|
@has_permissions(administrator=True)
|
||||||
|
|
Reference in a new issue