我如何检查所有的语音频道,看看是否有人在其中



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

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")

您可以遍历所有语音通道成员,找到最多的通道。

相关内容

最新更新