Esempio n. 1
0
    def __init__(self, prefix, config, aiohttp=None, **options):
        if 'formatter' not in options:
            options['formatter'] = Formatter(width=150)

        super().__init__(prefix, owner_id=config.owner, **options)
        self._runas = None
        self.remove_command('help')

        @self.group(invoke_without_command=True)
        @bot_has_permissions(embed_links=True)
        @cooldown(1, 10, commands.BucketType.guild)
        async def help(ctx, *commands_: str):
            """Shows all commands you can use on this server.
            Use {prefix}{name} all to see all commands"""
            await self._help(ctx, *commands_)

        @help.command(name='all')
        @bot_has_permissions(embed_links=True)
        @cooldown(1, 10, commands.BucketType.guild)
        async def all_(ctx, *commands_: str):
            """Shows all available commands even if you don't have the correct
            permissions to use the commands. Bot owner only commands are still hidden tho"""
            await self._help(ctx, *commands_, type=Formatter.Generic)

        log.debug('Using loop {}'.format(self.loop))
        if aiohttp is None:
            aiohttp = ClientSession(loop=self.loop)

        self.aiohttp_client = aiohttp
        self.config = config
        self.voice_clients_ = {}
        self._error_cdm = CooldownMapping(
            commands.Cooldown(2, 5, commands.BucketType.guild))
Esempio n. 2
0
from discord import Game
from discord.ext.commands import AutoShardedBot, when_mentioned_or

from bot.formatter import Formatter
from bot.utils import CaseInsensitiveDict

bot = AutoShardedBot(
    command_prefix=when_mentioned_or(
        ">>> self.", ">> self.", "> self.", "self.",
        ">>> bot.", ">> bot.", "> bot.", "bot.",
        ">>> ", ">> ", "> ",
        ">>>", ">>", ">"
    ),  # Order matters (and so do commas)
    activity=Game(name="with snekky sneks"),
    help_attrs={"aliases": ["help()"]},
    formatter=Formatter()
)

# Make cog names case-insensitive
bot.cogs = CaseInsensitiveDict()

# Global aiohttp session for all cogs - uses asyncio for DNS resolution instead of threads, so we don't *spam threads*
bot.http_session = ClientSession(connector=TCPConnector(resolver=AsyncResolver()))

# Internal/debug
bot.load_extension("bot.cogs.logging")
bot.load_extension("bot.cogs.security")


# Commands, etc
bot.load_extension("bot.cogs.snakes")
Esempio n. 3
0
def default_formatter(default_tags, default_replace):
    return Formatter(default_tags, default_replace)