Пример #1
0
    async def mute_list(self, ctx):
        """(List all muted users)
         
        Example:
        mute list
        """

        bl_members = []
        bl_reason = []
        bl_author = []
        position = 1

        mutesSql = MutesSql(self.bot)
        rs = await mutesSql.get_all_server_mute_users(ctx.guild.id)
        if len(rs) > 0:
            for key, value in rs.items():
                member_name = f"{ctx.guild.get_member(value['discord_user_id'])}"
                author_name = BotUtils.get_member_name_by_id(
                    self, ctx, value["discord_author_id"])
                bl_author.append(author_name)
                bl_members.append(f"{position}) {member_name}")
                if value["reason"] is None:
                    bl_reason.append("---")
                else:
                    bl_reason.append(value["reason"])
                position += 1

            members = '\n'.join(bl_members)
            reason = '\n'.join(bl_reason)
            author = '\n'.join(bl_author)

            embed = discord.Embed(
                description="*`Members that cannot type anything`*",
                color=discord.Color.red())
            embed.set_footer(text=f"For more info: {ctx.prefix}help mute")
            embed.set_author(name="Muted members in this server:\n\n",
                             icon_url=f"{ctx.guild.icon_url}")
            embed.add_field(name="Member",
                            value=Formatting.inline(members),
                            inline=True)
            embed.add_field(name="Added by",
                            value=Formatting.inline(author),
                            inline=True)
            embed.add_field(name="Reason",
                            value=Formatting.inline(reason),
                            inline=True)

            await BotUtils.send_embed(self, ctx, embed, False)
        else:
            await BotUtils.send_error_msg(
                self, ctx, "There are no muted members in this server.")
Пример #2
0
    async def mute_add(self, ctx, member: discord.Member, *, reason=None):
        """(Mute an user)

        Example:
        mute add member#1234 reason
        """

        if member.id == self.bot.owner.id:
            await BotUtils.send_error_msg(self, ctx,
                                          "The Bot Owner cannot be muted.")
            return
        if member.id == self.bot.user.id:
            await BotUtils.send_error_msg(self, ctx,
                                          "The Bot itself cannot be muted.")
            return
        if member.id == ctx.message.author.id:
            await BotUtils.send_error_msg(self, ctx,
                                          "You cannot mute yourself.")
            return
        if BotUtils.is_server_owner(ctx, member):
            await BotUtils.send_error_msg(
                self, ctx, "You cannot mute the Server's Owner.")
            return

        serverConfigsSql = ServerConfigsSql(self.bot)
        rs = await serverConfigsSql.get_server_configs(ctx.guild.id)
        if BotUtils.is_member_admin(member) and rs[0]["mute_admins"] == 'N':
            await BotUtils.send_error_msg(self, ctx,
                                          "You cannot mute a Server's Admin.")
            return

        if reason is not None and len(reason) > 29:
            await BotUtils.send_error_msg(self, ctx,
                                          "Reason has too many characters.")
            return

        mutesSql = MutesSql(self.bot)
        rs = await mutesSql.get_server_mute_user(member)
        if len(rs) == 0:
            await mutesSql.insert_mute_user(member, ctx.message.author, reason)
            msg = f"Successfully muted {member}"
            color = self.bot.settings["EmbedColor"]
            if reason is not None:
                msg += f"\nReason: {reason}"
            await BotUtils.send_msg(self, ctx, color, Formatting.inline(msg))
        else:
            msg = f"{member} is already muted."
            if rs[0]["reason"] is not None:
                msg += f"\nReason: {reason}"
            await BotUtils.send_error_msg(self, ctx, msg)
Пример #3
0
    async def mute_remove_all_users(self, ctx):
        """(Remove all muted users)
         
        Example:
        mute removeall
        """

        mutesSql = MutesSql(self.bot)
        rs = await mutesSql.get_all_server_mute_users(ctx.guild.id)
        if len(rs) > 0:
            color = self.bot.settings["EmbedColor"]
            await mutesSql.delete_all_mute_users(ctx.guild.id)
            await BotUtils.send_msg(self, ctx, color,
                                    "Successfully unmuted all members.")
        else:
            await BotUtils.send_error_msg(
                self, ctx, "There are no muted members in this server.")
Пример #4
0
    async def mute_remove_user(self, ctx, *, member: discord.Member):
        """(Remove muted user)
         
        Example:
        mute remove member#1234
        """

        if member is not None:
            mutesSql = MutesSql(self.bot)
            rs = await mutesSql.get_server_mute_user(member)
            if len(rs) > 0:
                msg = f"Successfully unmuted {member}."
                color = self.bot.settings["EmbedColor"]
                await mutesSql.delete_mute_user(member)
                await BotUtils.send_msg(self, ctx, color,
                                        Formatting.inline(msg))
                await ctx.send(f"{member.mention}")
            else:
                msg = f"{member} is not muted."
                await BotUtils.send_error_msg(self, ctx, msg)
        else:
            msg = f"Member {member} not found"
            await BotUtils.send_error_msg(self, ctx, msg)