我想制作一个机器人,告诉您语音通道中昵称以“ 5”开头的人,如果语音通道中昵称不超过6人,则@oneyone从5开始。我什至不知道从哪里开始。
答案 0 :(得分:0)
此处的关键是使用converter从命令调用中获取VoiceChannel
对象,然后使用该对象查看该通道内成员的显示名称。
from discord import VoiceChannel
from discord.ext import commands
bot = commands.Bot("!")
@bot.command()
async def count_fives(ctx, channel: VoiceChannel):
num_fives = sum(member.display_name.startswith("5") for member in channel.members)
if num_fives < 6:
await ctx.send(f"{ctx.guild.default_role} there are not enough people in the channel.")
bot.run("token")