我需要机器人检测谁在服务器中被静音并将其输出到文本通道
import discord
intents = discord.Intents.all()
intents.voice_states = True
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('logged as {0.user}'.format(client))
@client.event
async def on_voice_state_update(member, before, after):
channel = discord.utils.get(member.guild.channels, name='sprava-serveru')
print(before)
print(after)
client.run([TOKEN])
on_voice_state_update 只返回 self_mute 和 self_deaf 属性,而不是 mute 或 deaf em>。我认为意图会解决这个问题,但我不知道如何解决。我尝试了 discord.Intents.all() 和 discord.Intents.default() 但没有任何效果。
print(before) 和 print(after) 的输出:
<VoiceState self_mute=False self_deaf=False self_stream=False suppress=False requested_to_speak_at=None channel=<VoiceChannel id=834407963245936661 name='Senát' rtc_region=None position=3 bitrate=64000 user_limit=0 category_id=834407913190850610>>
<VoiceState self_mute=False self_deaf=False self_stream=False suppress=False requested_to_speak_at=None channel=<VoiceChannel id=834407963245936661 name='Senát' rtc_region=None position=3 bitrate=64000 user_limit=0 category_id=834407913190850610>>
谢谢
答案 0 :(得分:0)
在打印 deaf
对象时看不到 mute
或 VoiceState
属性没关系,如果您查看文档,它显然具有属性您正在寻找:VoiceState.deaf
、VoiceState.mute