本文整理匯總了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