2020-09-01 10:58:35 +03:00
from discord . ext import commands
from discord . ext . commands import Cog
2023-03-09 23:01:10 +01:00
from robocop_ng . helpers . checks import check_if_staff
2020-09-01 10:58:35 +03:00
class ModReswitched ( Cog ) :
def __init__ ( self , bot ) :
self . bot = bot
@commands.guild_only ( )
@commands.command ( aliases = [ " pingmods " , " summonmods " ] )
async def pingmod ( self , ctx ) :
2020-09-01 21:18:17 +03:00
""" Pings mods, only use when there ' s an emergency. """
2023-04-05 12:10:18 +02:00
can_ping = any ( r . id in self . bot . config . pingmods_allow for r in ctx . author . roles )
2020-09-01 10:58:35 +03:00
if can_ping :
await ctx . send (
2023-04-05 12:10:18 +02:00
f " <@& { self . bot . config . pingmods_role } >: { ctx . author . mention } needs assistance. "
2020-09-01 10:58:35 +03:00
)
else :
await ctx . send (
2020-09-01 21:18:17 +03:00
f " { ctx . author . mention } : You need the community role to be able to ping the entire mod team, please pick an online mod (not staff, please!), and ping them instead. "
2020-09-01 10:58:35 +03:00
)
@commands.guild_only ( )
@commands.check ( check_if_staff )
2020-11-04 19:01:19 +03:00
@commands.command ( aliases = [ " togglemod " ] )
2020-09-01 10:58:35 +03:00
async def modtoggle ( self , ctx ) :
""" Toggles your mod role, staff only. """
2023-04-05 12:10:18 +02:00
target_role = ctx . guild . get_role ( self . bot . config . modtoggle_role )
2020-09-01 10:58:35 +03:00
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. " )
2022-05-24 20:35:42 +02:00
async def setup ( bot ) :
await bot . add_cog ( ModReswitched ( bot ) )