本文整理汇总了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)
示例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
示例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')
示例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
示例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__()}')
示例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