本文整理汇总了Python中discord.VoiceState方法的典型用法代码示例。如果您正苦于以下问题:Python discord.VoiceState方法的具体用法?Python discord.VoiceState怎么用?Python discord.VoiceState使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类discord
的用法示例。
在下文中一共展示了discord.VoiceState方法的4个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: on_voice_state_update
# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
def on_voice_state_update(self, member: discord.Member, before: discord.VoiceState, after: discord.VoiceState):
if member.bot:
return
player: Player = self.bot.wavelink.get_player(member.guild.id, cls=Player)
if not player.channel_id or not player.context:
player.node.players.pop(member.guild.id)
return
channel = self.bot.get_channel(int(player.channel_id))
if member == player.dj and after.channel is None:
for m in channel.members:
if m.bot:
continue
else:
player.dj = m
return
elif after.channel == channel and player.dj not in channel.members:
player.dj = member
示例2: on_voice_state_update
# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
def on_voice_state_update(self, member: Member, before: VoiceState, after: VoiceState) -> None:
# pylint: disable=unused-argument
# If we're the only one left in a voice chat, leave the channel
guild = getattr(after.channel, 'guild', None)
if guild is None:
return
voice = guild.voice_client
if voice is None or not voice.is_connected():
return
if len(voice.channel.voice_members) == 1:
await voice.disconnect()
示例3: on_voice_state_update
# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
def on_voice_state_update(
self, member, before: discord.VoiceState, after: discord.VoiceState
):
if not after.channel:
return
guild = after.channel.guild
bot_in_room = guild.me in after.channel.members
if bot_in_room:
self.upsert(rgetattr(member, "guild.id", -1), "users_joined_bot_music_room")
示例4: on_voice_state_update
# 需要导入模块: import discord [as 别名]
# 或者: from discord import VoiceState [as 别名]
def on_voice_state_update(self, member, before, after):
"""
Starts events when a user changes their voice state.
Such as connecting, disconnecting and moving between channels.
:type member: discord.Member
:type before: discord.VoiceState
:type after: discord.VoiceState
:param member: The member that changed their voice state.
:param before: The member as they were before the change.
:param after: The member as they are after the change.
:return:
"""
if not member.bot:
payload = VoiceStateUpdatePayload(self, member, before, after)
self.loop.create_task(self.queue.event_runner('voice_state_update', payload))