Example #1
0
 def __init__(self, **options):
     command_attrs = options.pop('command_attrs', {})
     command_attrs.update(
         cooldown=commands.Cooldown(1, 3.0, commands.BucketType.user),
         max_concurrency=commands.MaxConcurrency(
             3, per=commands.BucketType.channel, wait=False),
         help='Shows help about the bot, a command, or a category')
     super().__init__(command_attrs=command_attrs, **options)
Example #2
0
def shared_max_concurrency(rate: int, per: commands.BucketType, *, wait=False):
    value = commands.MaxConcurrency(rate, per=per, wait=wait)

    def decorator(func: typing.Union[commands.Command, typing.Callable[..., typing.Coroutine]]):
        if isinstance(func, commands.Command):
            func._max_concurrency = value
        else:
            func.__commands_max_concurrency__ = value
        return func

    return decorator
Example #3
0
 def __init__(self, bot):
     super().__init__(bot)
     self.channels: typing.Mapping[int, T] = collections.defaultdict(
         lambda: self._gamecls(self.bot))
     self._max_concurrency = commands.MaxConcurrency(
         1, per=commands.BucketType.channel, wait=False)
Example #4
0
import asyncio
import logging
import random
from datetime import datetime
from typing import Callable, Optional

import discord
from discord.ext import commands

from crimsobot.bot import CrimsoBOT
from crimsobot.utils import image as imagetools, tools as c

log = logging.getLogger(__name__)

eface_bucket = commands.MaxConcurrency(1, per=commands.BucketType.user, wait=False)


def shared_max_concurrency(bucket: commands.MaxConcurrency) -> Callable[[Callable], Callable]:
    def decorator(func: Callable) -> Callable:
        if isinstance(func, commands.Command):
            func._max_concurrency = bucket
        else:
            func.__commands_max_concurrency__ = bucket  # type: ignore
        return func
    return decorator


class Image(commands.Cog):
    def __init__(self, bot: CrimsoBOT):
        self.bot = bot
Example #5
0
 def __init__(self):
     super().__init__(command_attrs={
         'aliases': ['h', 'commands'],
         'max_concurrency': commands.MaxConcurrency(2, per=commands.BucketType.member, wait=False),
         'help': 'Starts an interactive session with a list of all available commands.'
     }, verify_checks=False)