From 565a7361e627922486040d53e3f13a5cba653b1a Mon Sep 17 00:00:00 2001 From: phxntxm Date: Thu, 4 Oct 2018 17:28:37 -0500 Subject: [PATCH] Add a notify command --- cogs/admin.py | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/cogs/admin.py b/cogs/admin.py index fd588b0..b451b7d 100644 --- a/cogs/admin.py +++ b/cogs/admin.py @@ -13,6 +13,28 @@ class Administration: def __init__(self, bot): self.bot = bot + @commands.command() + @commands.guild_only() + @utils.can_run(manage_guild=True) + async def notify(self, ctx, role: discord.Role, *, message): + """ + Notify everyone in "role" with "message" + This sets the role to mentionable, mentions the role, then sets it back + """ + if not ctx.me.guild_permissions.manage_roles: + await ctx.send("I do not have permissions to edit roles") + return + try: + await role.edit(mentionable=True) + except discord.Forbidden: + await ctx.send("I do not have permissions to edit that role. " + "(I either don't have manage roles permissions, or it is higher on the hierarchy)") + else: + fmt = "{}\n{}".format(role.mention, message) + await ctx.send(fmt) + await role.edit(mentionable=False) + await ctx.message.delete() + @commands.group(invoke_without_command=True) @commands.guild_only() @utils.can_run(send_messages=True)