当前位置: 首页>>代码示例>>Python>>正文


Python commands.AutoShardedBot方法代码示例

本文整理汇总了Python中discord.ext.commands.AutoShardedBot方法的典型用法代码示例。如果您正苦于以下问题:Python commands.AutoShardedBot方法的具体用法?Python commands.AutoShardedBot怎么用?Python commands.AutoShardedBot使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在discord.ext.commands的用法示例。


在下文中一共展示了commands.AutoShardedBot方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: __new__

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import AutoShardedBot [as 别名]
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) 
开发者ID:PythonistaGuild,项目名称:Wavelink,代码行数:25,代码来源:client.py

示例2: __init__

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import AutoShardedBot [as 别名]
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 
开发者ID:PythonistaGuild,项目名称:Wavelink,代码行数:18,代码来源:player.py

示例3: __init__

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import AutoShardedBot [as 别名]
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') 
开发者ID:PythonistaGuild,项目名称:Wavelink,代码行数:10,代码来源:client.py

示例4: _get_shard_socket

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import AutoShardedBot [as 别名]
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 
开发者ID:PythonistaGuild,项目名称:Wavelink,代码行数:8,代码来源:player.py

示例5: connect

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import AutoShardedBot [as 别名]
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__()}') 
开发者ID:PythonistaGuild,项目名称:Wavelink,代码行数:13,代码来源:node.py

示例6: generate_client

# 需要导入模块: from discord.ext import commands [as 别名]
# 或者: from discord.ext.commands import AutoShardedBot [as 别名]
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 
开发者ID:BaseChip,项目名称:RulesBot,代码行数:17,代码来源:main.py


注:本文中的discord.ext.commands.AutoShardedBot方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。