From ffb129770d559653d0a14ee294e8089039068925 Mon Sep 17 00:00:00 2001 From: Ave Date: Tue, 1 Sep 2020 10:58:35 +0300 Subject: [PATCH] mod_reswitched: Push --- cogs/mod_reswitched.py | 45 ++++++++++++++++++++++++++++++++++++++++++ config_template.py | 5 +++++ 2 files changed, 50 insertions(+) create mode 100644 cogs/mod_reswitched.py diff --git a/cogs/mod_reswitched.py b/cogs/mod_reswitched.py new file mode 100644 index 0000000..898e802 --- /dev/null +++ b/cogs/mod_reswitched.py @@ -0,0 +1,45 @@ +import config +from discord.ext import commands +from discord.ext.commands import Cog +from helpers.checks import check_if_staff + + +class ModReswitched(Cog): + def __init__(self, bot): + self.bot = bot + + @commands.guild_only() + @commands.command(aliases=["pingmods", "summonmods"]) + async def pingmod(self, ctx): + """Pings mods, only use when there's an emergency and such.""" + can_ping = any(r.id in config.pingmods_allow for r in ctx.author.roles) + if can_ping: + await ctx.send( + f"<@&{config.pingmods_role}>: {ctx.author.mention} needs assistance." + ) + else: + await ctx.send( + f"{ctx.author.mention}: You need community to be able to ping the entire staff team, please pick an online staff member, check if they have the mod role, and ping them instead." + ) + + @commands.guild_only() + @commands.check(check_if_staff) + @commands.command() + async def modtoggle(self, ctx): + """Toggles your mod role, staff only.""" + target_role = ctx.guild.get_role(config.modtoggle_role) + + if target_role in ctx.author.roles: + await ctx.author.remove_roles( + target_role, reason="Staff self-unassigned mod role" + ) + await ctx.send(f"{ctx.author.mention}: Removed your mod role.") + else: + await ctx.author.add_roles( + target_role, reason="Staff self-assigned mod role" + ) + await ctx.send(f"{ctx.author.mention}: Gave you mod role.") + + +def setup(bot): + bot.add_cog(ModReswitched(bot)) diff --git a/config_template.py b/config_template.py index dbcb7d5..638052b 100644 --- a/config_template.py +++ b/config_template.py @@ -318,3 +318,8 @@ list_channels = [] self_assignable_roles = { "streamnotifs": 715158689060880384, } + +# == Only if you want to use cogs.mod_reswitched == +pingmods_allow = [named_roles["community"]] + staff_role_ids +pingmods_role = 360138431524765707 +modtoggle_role = 360138431524765707