我想做一个机器人,告诉你有多少人在语音通道中,他们的昵称以' 5‘开头,如果在语音通道中的人少于6个,昵称以5开头,则@everyone。如果你理解的话。我甚至不知道从哪里开始。
发布于 2019-12-27 23:19:12
这里的关键是使用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")https://stackoverflow.com/questions/59498537
复制相似问题