Skip to content

Make an automute function based on a list of key words #1020

@ajax146

Description

@ajax146

@TheKrol

Improve upon this code, and make the timeout a configurable list of strings instead of a hardcoded item

import munch
from core import auxiliary, cogs
from discord.ext import commands
from datetime import timedelta


async def setup(bot):
    await bot.add_cog(AutoMute(bot=bot, extension_name="automute"))


class AutoMute(cogs.MatchCog):
    """Class for the autoreact to make it to discord."""

    async def match(
        self, config: munch.Munch, _: commands.Context, content: str
    ) -> bool:
        """A match function to determine if somehting should be reacted to

        Args:
            config (munch.Munch): The guild config for the running bot
            content (str): The string content of the message

        Returns:
            bool: True if there needs to be a reaction, False otherwise
        """
        if content.startswith("?8350"):
            return True

    async def response(
        self, config: munch.Munch, ctx: commands.Context, content: str, _: bool
    ):
        """The function to generate and add reactions

        Args:
            config (munch.Munch): The guild config for the running bot
            ctx (commands.Context): The context in which the message was sent in
            content (str): The string content of the message
        """
        await ctx.author.timeout(timedelta(seconds=60))

Metadata

Metadata

Assignees

Labels

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions