我有一个命令,我为服务器选择一个随机成员,但由于某种原因,每当我运行它时,它只提到自己......好像它无法检测到服务器中除了自己之外还有其他成员.这是代码: 好的
client = commands.Bot(command_prefix=['%', "v", "V"],
case_insensitive=True,
help_command=None)
intents = discord.Intents().all()
intents = True
@client.event
async def on_ready():
print('Bot is Online! ;)')
servers = len(client.guilds)
members = 0
for guild in client.guilds:
members += guild.member_count - 1
await client.change_presence(activity=discord.Activity(
type=discord.ActivityType.watching,
name=f'{servers} servers and {members} members | %help'))
@client.command()
async def choosemem(ctx):
guild = ctx.guild
await ctx.send(f"{random.choice(guild.members).mention} has been chosen")
这是完整的代码,包括状态和意图。
答案 0 :(得分:0)
您还需要在 client= commands.Bot 中添加意图值
intents = discord.Intents().all()
client = commands.Bot(command_prefix=['%', "v", "V"],
case_insensitive=True,
help_command=None,
intents = intents)