示例#1
0
    def __init__(
        self,
        bot: Bot,
        commands_file: str,
        guild_admin_permission: bool = True,
        bot_admin_permission: bool = True,
        everyone_permission: bool = False,
    ) -> None:
        """Init Commands

        Args:
            bot (Bot): bot that loaded this cog
            commands_file (str): path to store database
            guild_admin_permission (bool): can guild admins start polls
            bot_admin_permission (bool): can bot admin start polls
            everyone_permission (bool): allow everyone to start polls
        """
        self.bot = bot
        self.guild_admin_permission = guild_admin_permission
        self.bot_admin_permission = bot_admin_permission
        self.everyone_permission = everyone_permission
        self.db = GuildDatabase(commands_file)

        # Register all commands on startup
        tables = self.db.tables()
        for table in tables.values():
            for name, text in table.items():
                self.bot.add_command(self.make_command(name, text))
示例#2
0
    def __init__(self, bot: Bot, mc_file: str) -> None:
        """Init Minecraft

        Args:
            bot (Bot): bot that loaded this cog
            mc_file (str): path to store database
        """
        self.bot = bot
        self.db = GuildDatabase(mc_file)
示例#3
0
    def __init__(self, bot: Bot, games_file: str) -> None:
        """Init Games

        Args:
            bot (Bot): bot that loaded this cog
            games_file (str): path to store database
        """
        self.bot = bot
        self.db = GuildDatabase(games_file)
示例#4
0
    def __init__(self,
                 bot: Bot,
                 database_path: str,
                 message_prefix: Optional[Union[str, List[str]]] = None,
                 whitelist_prefix: Union[str, List[str]] = [],
                 max_offenses: int = 3,
                 allow_deletes: bool = True,
                 allow_edits: bool = True,
                 allow_wrong_commands: bool = True,
                 booster_exception: bool = True,
                 invite_after_kick: bool = True) -> None:
        """Init Rules

        Args:
            bot (Bot): bot object this cog is attached to
            database_path (str): path to file storing database of strikes
            message_prefix (str, list[str]): valid prefixes for messages. If None, no
                message prefix checking is done.
            whitelist_prefix (str, list[str]): messages starting with these prefixes will
                be ignored. Useful for ignoring the command prefixes of
                other bots.
            max_offenses (int): maximum strikes before being kicked
            allow_deletes (bool): if false, the bot will notify the channel if
                a message is deleted
            allow_edits (bool): if false, the bot will notify the channel if
                a message is edited
            allow_wrong_commands (bool): if false, members will be given a strike
                for trying to use invalid commands
            booster_exception (bool): boosters are exempt from rules
            invite_after_kick (bool): send invite link if member is kicked
        """
        self.bot = bot
        if isinstance(message_prefix, str):
            message_prefix = [message_prefix]
        self.message_prefix = message_prefix
        if isinstance(whitelist_prefix, str):
            message_prefix = [whitelist_prefix]
        self.whitelist_prefix = whitelist_prefix
        self.max_offenses = max_offenses
        self.allow_deletes = allow_deletes
        self.allow_edits = allow_edits
        self.allow_wrong_commands = allow_wrong_commands
        self.booster_exception = booster_exception
        self.invite_after_kick = invite_after_kick

        if self.message_prefix is not None:
            self.bot.guild_message_prefix = self.message_prefix[0]

        self.db = GuildDatabase(database_path)
示例#5
0
    def __init__(
        self,
        bot: Bot,
        sounds_file: str,
        sounds_dir: str,
    ) -> None:
        """Init Voice

        Args:
            bot (Bot): bot that loaded this cog
            sounds_file (str): path to store sounds database
            sounds_dir (str): directory to store audio files in
        """
        self.bot = bot

        # Note: sounds stored as ./<sounds_dir>/<guild_id>/<sound_name>.mp3
        self.sounds_dir = sounds_dir
        self.db = GuildDatabase(sounds_file)

        self.rebuild_database()
        self._leave_on_empty.start()