async def remove_mute_role(self, context, arg=None):
     server = context.guild.id
     if server not in self.bot_data:
         self.bot_data[server] = utils.default_server_data()
     message = remove_role_from(self.bot_data[server]["mute_roles"], arg,
                                "Removed {} from roles that can mute.",
                                "That role already can't mute.")
     await context.send(message)
 async def add_mute_role(self, context, arg=None):
     server = context.guild.id
     if server not in self.bot_data:
         self.bot_data[server] = utils.default_server_data()
     message = add_role_to(self.bot_data[server]["mute_roles"], arg,
                           "Added {} to roles that can mute.",
                           "That role can already mute.")
     await context.send(message)
 async def set_mute_role(self, context, arg=None):
     server = context.guild.id
     if server not in self.bot_data:
         self.bot_data[server] = utils.default_server_data()
     self.bot_data[server]["mute_role"], message = set_role_to(
         self.bot_data[server]["mute_role"], arg,
         "Set {} to the muted role.", "That role is already set.")
     await context.send(message)
 async def clear_mute_role(self, context):
     server = context.guild.id
     if server not in self.bot_data:
         self.bot_data[server] = utils.default_server_data()
     if self.bot_data[server]["mute_role"] == 0:
         await context.send("No role was set?")
     else:
         self.bot_data[server]["mute_role"] = 0
         await context.send("Muted role cleared.")
    async def toggle_callout_delete(self, context, arg=None):
        server = context.guild.id
        if server not in self.bot_data:
            self.bot_data[server] = utils.default_server_data()

        self.bot_data[server][
            "callout_delete_enabled"], message = toggle_feature(
                arg, "callout_delete", self.enable_phrases,
                self.disable_phrases,
                self.bot_data[server]["callout_delete_enabled"])
        await context.send(message)
 async def callout_delete(self, message: discord.Message):
     server = message.guild.id
     if server not in self.bot_data:
         self.bot_data[server] = utils.default_server_data()
     try:
         if self.bot_data[server][
                 "callout_delete_enabled"] and not message.author.bot and await check_audit_message_delete(
                     message, message.author):
             await message.channel.send(
                 random.sample(self.remind_delete_phrases,
                               1)[0].format(message.content,
                                            mention(message.author.id)))
     except discord.errors.Forbidden as ex:
         if ex.code == 50013:
             self.bot_data[server]["callout_delete_enabled"] = False
             await message.channel.send(
                 "I need permission to view the audit log to call out deletes. Disabling."
             )
    async def mute(self, context, arg=None, *reason):
        server = context.guild.id
        if server not in self.bot_data:
            self.bot_data[server] = utils.default_server_data()

        member = utils.get_user_from_mention(context.guild, arg)

        if not role_check(context.author.roles,
                          self.bot_data[server]["mute_roles"]):
            await context.send("You lack the role required to mute.")
        elif self.bot_data[server]["mute_role"] == 0:
            await context.send(
                "You need to assign a mute role via `;set_mute_role @role` first."
            )
        elif not member:
            await context.send(
                "That doesn't appear to be a user on your server.")
        elif role_check(member.roles, self.bot_data[server]["mute_roles"]):
            await context.send("You can't mute the muters.")
        else:
            role = context.guild.get_role(
                int(self.bot_data[server]["mute_role"]))
            await member.add_roles(role,
                                   reason="{} muted because: \"{}\"".format(
                                       context.author.name, " ".join(reason)))
            if reason:
                await member.add_roles(
                    role,
                    reason="{} muted because: \"{}\"".format(
                        context.author.name, " ".join(reason)))
                await context.send("Muted for 30 minutes for: \"{}\"".format(
                    " ".join(reason)))
            else:
                await member.add_roles(role,
                                       reason="{} muted them.".format(
                                           context.author.name))
                await context.send("Muted for 30 minutes.")
            utils.rm_id_from_bot_data(self.bot_data, server, member.id,
                                      "muted_users")
            self.bot_data[server]["muted_users"].add(
                (member.id, datetime.utcnow() + timedelta(minutes=30)))
    async def warn(self, context, arg=None, *reason):
        server = context.guild.id
        if server not in self.bot_data:
            self.bot_data[server] = utils.default_server_data()

        member = utils.get_user_from_mention(context.guild, arg)
        warn_role = context.guild.get_role(
            int(self.bot_data[server]["warn_role"]))

        if not role_check(context.author.roles,
                          self.bot_data[server]["warn_roles"]):
            await context.send("You lack the role required to warn.")
        elif not warn_role:
            await context.send(
                "You need to assign a valid warn role via `;set_warn_role @role` first."
            )
        elif not member:
            await context.send(
                "That doesn't appear to be a user on your server.")
        elif role_check(member.roles, self.bot_data[server]["warn_roles"]):
            await context.send("You can't warn the warners.")
        elif role_check(member.roles, {warn_role.id}):
            mute_role = context.guild.get_role(
                int(self.bot_data[server]["warn_role"]))
            if not mute_role:
                await context.send(
                    "You need to assign a valid mute role via `;set_mute_role @role` before the "
                    "double-warn -> mute can happen.")
            elif reason:
                await member.add_roles(
                    mute_role,
                    reason="{} did the 2nd warn for: \"{}\"".format(
                        context.author.name, " ".join(reason)))
                await context.send(
                    "Due to double warn, muted for 30 minutes for: \"{}\"".
                    format(" ".join(reason)))
                utils.rm_id_from_bot_data(self.bot_data, server, member.id,
                                          "muted_users")
                self.bot_data[server]["muted_users"].add(
                    (member.id, datetime.utcnow() + timedelta(minutes=30)))
            else:
                await member.add_roles(mute_role,
                                       reason="{} did the 2nd warn.".format(
                                           context.author.name))
                await context.send("Due to double warn, muted for 30 minutes.")
                utils.rm_id_from_bot_data(self.bot_data, server, member.id,
                                          "muted_users")
                self.bot_data[server]["muted_users"].add(
                    (member.id, datetime.utcnow() + timedelta(minutes=30)))
        else:
            if reason:
                await member.add_roles(
                    warn_role,
                    reason="{} warned because: \"{}\"".format(
                        context.author.name, " ".join(reason)))
                await context.send("Warned for 30 seconds for: \"{}\"".format(
                    " ".join(reason)))
            else:
                await member.add_roles(warn_role,
                                       reason="{} warned them.".format(
                                           context.author.name))
                await context.send("Warned for 30 minutes.")
            utils.rm_id_from_bot_data(self.bot_data, server, member.id,
                                      "warned_users")
            self.bot_data[server]["warned_users"].add(
                (member.id, datetime.utcnow() + timedelta(minutes=30)))