python - 如何检查所有语音通道以查看是否有人在其中?
问题描述
我正在尝试制作一个机器人,它可以检查所有语音频道,看看是否有人在其中,然后加入人数最多的频道,然后播放声音。我在下面附上了我的代码。
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")
解决方案
您可以遍历所有语音频道成员以找到最多的频道。
推荐阅读
- python - Python 2.7 出现错误 TypeError: 不支持的操作数类型 /: 'datetime.timedelta' 和 'datetime.timedelta'
- python - ImportError:无法从“keras.optimizers”导入名称“rmsprop”
- c# - Wpf:ContentControl.AddChild(Object) 方法
- python - 在 beautifulsoup4 中选择 div ID
- python - Tkinter 按钮复制
- mule - 连接器在用于枚举的 mule3 自定义连接器的下拉过程中显示一个空字段
- android - 在哪里查找含义“adb screencap”命令的退出代码或如何以编程方式获取含义?
- python - 复制坐标区内容并将其显示在现有图形中
- r - 如果需要,使用 NA 将元素插入到向量中
- python-3.x - 在 cupy 中启用 cub 的正确方法是什么?