第七色在线视频,2021少妇久久久久久久久久,亚洲欧洲精品成人久久av18,亚洲国产精品特色大片观看完整版,孙宇晨将参加特朗普的晚宴

為了賬號安全,請及時綁定郵箱和手機立即綁定
已解決430363個問題,去搜搜看,總會有你想問的

為什么我的discord.py 事件沒有被調(diào)用?

為什么我的discord.py 事件沒有被調(diào)用?

開滿天機 2023-10-18 15:45:10
我希望讓機器人在用戶加入頻道時上線,并在用戶離開頻道時離線。我對discord.js很陌生,但這是我的代碼:@client.eventasync def on_ready():    await client.change_presence(status=discord.Status.offline)    print("Bot ready")@client.eventasync def on_voice_state_update(member, before, after):    if before.channel is None and after.channel is not None:        if after.channel.id == [""Channel ID 1""] or after.channel.id == [""Channel ID 2""]:            await client.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name="users | Ready to mute"))            print("Bot done0")            print(member, "joined")@client.eventasync def on_voice_state_update(member, before, after):    if before.channel is not None and after.channel is None:        if before.channel.id == [""Channel ID 1""] or before.channel.id == [""Channel ID 2""]:            await client.change_presence(status=discord.Status.offline)            print("Bot done1")            print(member, "left")我當(dāng)然會將“Channel ID 1”和“Channel ID 2”替換為通道 ID。謝謝你的幫助!
查看完整描述

1 回答

?
眼眸繁星

TA貢獻(xiàn)1873條經(jīng)驗 獲得超9個贊

您有 2 個名為:“on_voice_state_update”的“def”,因此當(dāng)此事件發(fā)生時,機器人不知道他必須調(diào)用哪一個。刪除 2 個“def”之一,并僅在一個名為“on_voice_state_update”的“def”中執(zhí)行您想要的操作。


@client.event

async def on_voice_state_update(member, before, after):

    if before.channel is None and after.channel is not None:

        if after.channel.id == [""Channel ID 1""] or after.channel.id == [""Channel ID 2""]:

            await client.change_presence(status=discord.Status.online, activity=discord.Activity(type=discord.ActivityType.listening, name="users | Ready to mute"))

            print("Bot done0")

            print(member, "joined")

    elif before.channel is not None and after.channel is None:

            if before.channel.id == [""Channel ID 1""] or before.channel.id == [""Channel ID 2""]:

                await client.change_presence(status=discord.Status.offline)

                print("Bot done1")

                print(member, "left")


查看完整回答
反對 回復(fù) 2023-10-18
  • 1 回答
  • 0 關(guān)注
  • 130 瀏覽
慕課專欄
更多

添加回答

舉報

0/150
提交
取消
微信客服

購課補貼
聯(lián)系客服咨詢優(yōu)惠詳情

幫助反饋 APP下載

慕課網(wǎng)APP
您的移動學(xué)習(xí)伙伴

公眾號

掃描二維碼
關(guān)注慕課網(wǎng)微信公眾號