Пример #1
0
    async def mute(
        self, ctx: Context, member: discord.Member, *, reason: str = "N/A"
    ) -> NoReturn:
        s = await Settings(ctx.guild.id)
        lang = await s.get_field("locale", CONFIG["default_locale"])
        STRINGS = Strings(lang)
        mute_role_id = await s.get_field("mute_role_id")

        if (
            mute_role_id is None
            or discord.utils.get(ctx.guild.roles, id=mute_role_id) is None
        ):
            embed = Utils.done_embed(STRINGS["moderation"]["on_mute_role_create"])
            await ctx.send(embed=embed)
            mute_role = await ctx.guild.create_role(name="OpenMod - Muted")

            await s.set_field("mute_role_id", mute_role.id)
            mute_role_id = await s.get_field("mute_role_id")

        else:
            mute_role = discord.utils.get(ctx.guild.roles, id=mute_role_id)

            for user_role in member.roles:
                if user_role == mute_role:
                    embed = Utils.error_embed(STRINGS["error"]["already_muted"])
                    await ctx.send(embed=embed)
                    return

        for channel in ctx.guild.text_channels:
            await channel.set_permissions(
                mute_role, read_messages=True, send_messages=False, speak=False
            )

        await member.add_roles(mute_role)
        await ctx.message.add_reaction(CONFIG["yes_emoji"])
Пример #2
0
    async def ping(self, ctx: Context) -> NoReturn:
        """Shows host latency."""
        s = await Settings(ctx.guild.id)
        lang = await s.get_field("locale", CONFIG["default_locale"])
        STRINGS = Strings(lang)
        latency = int(round(self.bot.latency * 100, 1))

        embed = Utils.done_embed(STRINGS["other"]["pong"].format(str(latency)))
        await ctx.send(embed=embed)
Пример #3
0
    async def purge(self, ctx: Context, number: int) -> NoReturn:
        """Deletes a specified number of messages in the current channel.

        Attributes:
        -----------
        - `number` - The number of messages to be deleted.

        """
        s = await Settings(ctx.guild.id)
        lang = await s.get_field("locale", CONFIG["default_locale"])
        STRINGS = Strings(lang)

        deleted = await ctx.channel.purge(limit=number + 1)

        embed = Utils.done_embed(STRINGS["moderation"]["on_clear"].format(len(deleted)))
        msg = await ctx.send(embed=embed)
        await asyncio.sleep(10)
        await msg.delete()