如何检查所有语音频道以查看是否有人在其中?

时间:2021-06-27 13:56:46

标签: python discord discord.py

我正在尝试制作一个机器人,它可以检查所有语音频道,看看是否有人在其中,然后加入人数最多的频道,然后播放声音。 我在下面附上了我的代码。

import discord
from discord.ext import commands
from discord.player import FFmpegPCMAudio
from discord.utils import get
import datetime

bot = commands.Bot(command_prefix="<")

@bot.event
async def on_ready():
    print("Bot is ready")
MINUTE = 0

@bot.command()
async def start(ctx):
    while not bot.is_closed():
        while not "00" in str(MINUTE):
            MINUTE = datetime.datetime.now().minute
            if "00" in str(MINUTE):
                hour = datetime.datetime.now().hour
                number = hour
                while number > 0:
                    # here is where I need the code to check all voice channels and find the one with the most people in
                    voice = await channel.connect()
                    source = FFmpegPCMAudio('audio source')
                    player = voice.play(source)
                    number = number-1



bot.run("my bot token")

1 个答案:

答案 0 :(得分:0)

您可以遍历所有 voice channel 成员以找到最多的频道。