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