Python discord.ext.commands.AutoShardedBot() Examples

The following are 6 code examples of discord.ext.commands.AutoShardedBot(). You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may also want to check out all available functions/classes of the module discord.ext.commands , or try the search function .
Example #1
Source File: client.py    From Wavelink with MIT License 6 votes vote down vote up
def __new__(cls, *args, **kwargs):
        cls.__qualname__ = 'wavelink.Client'

        try:
            bot = kwargs['bot']
        except KeyError:
            msg = 'wavelink.Client: bot is a required keyword only argument which is missing.'
            raise WavelinkException(msg)

        if not isinstance(bot, (commands.Bot, commands.AutoShardedBot)):
            msg = f'wavelink.Client expected type <commands.Bot or commands.AutoShardedBot> not {type(bot)}'
            raise TypeError(msg)

        try:
            update_handlers = bot.extra_events['on_socket_response']
        except KeyError:
            return super().__new__(cls)

        for handler in update_handlers:
            if handler.__self__.__class__.__qualname__ == 'wavelink.Client':
                bot.remove_listener(handler, 'on_socket_response')

        return super().__new__(cls) 
Example #2
Source File: player.py    From Wavelink with MIT License 6 votes vote down vote up
def __init__(self, bot: Union[commands.Bot, commands.AutoShardedBot], guild_id: int, node, **kwargs):
        self.bot = bot
        self.guild_id = guild_id
        self.node = node

        self.last_update = None
        self.last_position = None
        self.position_timestamp = None

        self._voice_state = {}

        self.volume = 100
        self.paused = False
        self.current = None
        self._equalizer = Equalizer.flat()
        self.channel_id = None 
Example #3
Source File: client.py    From Wavelink with MIT License 5 votes vote down vote up
def __init__(self, bot: Union[commands.Bot, commands.AutoShardedBot]):
        self.bot = bot
        self.loop = bot.loop or asyncio.get_event_loop()
        self.session = aiohttp.ClientSession(loop=self.loop)

        self.nodes = {}

        bot.add_listener(self.update_handler, 'on_socket_response') 
Example #4
Source File: player.py    From Wavelink with MIT License 5 votes vote down vote up
def _get_shard_socket(self, shard_id: int) -> Optional[DiscordWebSocket]:
        if isinstance(self.bot, commands.AutoShardedBot):
            return self.bot.shards[shard_id].ws

        if self.bot.shard_id is None or self.bot.shard_id == shard_id:
            return self.bot.ws 
Example #5
Source File: node.py    From Wavelink with MIT License 5 votes vote down vote up
def connect(self, bot: Union[commands.Bot, commands.AutoShardedBot]) -> None:
        self._websocket = WebSocket(node=self,
                                    host=self.host,
                                    port=self.port,
                                    password=self.password,
                                    shard_count=self.shards,
                                    user_id=self.uid,
                                    secure=self.secure)
        await self._websocket._connect()

        __log__.info(f'NODE | {self.identifier} connected:: {self.__repr__()}') 
Example #6
Source File: main.py    From RulesBot with MIT License 4 votes vote down vote up
def generate_client(loop=None):
    client: commands.Bot = commands.AutoShardedBot(
        command_prefix=get_server_prefix,
        loop=loop
    )

    client.remove_command('help')

    for module in MODULES:
        client.load_extension(module)

    client.event(on_command_error)
    client.event(on_error)

    return client