【问题标题】:python discord bot temporary voice channelspython discord bot 临时语音通道
【发布时间】:2020-09-16 02:27:51
【问题描述】:

语音频道仅在我静音、耳聋或开始/停止流式传输时出现当我加入“➕Kanal Erstellen➕”频道时如何解决此问题如何立即进入临时频道?

    async def on_voice_state_update(self, member, before, after):
        if member.bot:
            return

        if not before.channel:
            print(f'{member.name} joined {after.channel.name}')

        if before.channel and not after.channel:
            print(f'{member.name} left {before.channel.name}')

        if before.channel and after.channel:
            if before.channel.id != after.channel.id:
                print(f'{member.name} switched from {before.channel.name} to {after.channel.name}')
            else:
                if member.voice.self_stream:
                    print(f'{member.name} started streaming')
                    self.current_streamers.append(member.id)
                elif member.voice.self_mute:
                    print(f'{member.name} muted')
                else:
                    for streamer in self.current_streamers:
                        if member.id == streamer:
                            if not member.voice.self_stream:
                                print(f'{member.name} stopped streaming')
                                self.current_streamers.remove(member.id)
                            break

                if after.channel is not None:
                    if after.channel.name == "➕Kanal Erstellen➕":
                        channel = await creat_voice_channel(after.channel.guild, f'{member.name}´s Callcenter'.lower(),
                                                            category_name="Temp")

                        if channel is not None:
                            await member.move_to(channel)

                if before.channel is not None:
                    if before.channel.category.id == get_category_by_name(before.channel.guild, "Temp").id:
                        print("User left Temp channel")
                        if len(before.channel.members) == 0:
                            print("channel empty")
                            await before.channel.delete()```

【问题讨论】:

    标签: python python-3.x discord discord.py


    【解决方案1】:

    我相信您的问题是if before.channel and after.channel:,当您最初加入频道时,不会有before.channel,因为您之前没有在频道中,并且您的代码不会运行。

    【讨论】:

      猜你喜欢
      • 2021-04-29
      • 1970-01-01
      • 1970-01-01
      • 2022-01-23
      • 2021-01-05
      • 2020-04-28
      • 2020-11-04
      • 2022-12-11
      • 2020-11-03
      相关资源
      最近更新 更多