您如何一次让Discord Server中的每个成员扮演一个角色Discord.py.py
我正在尝试通过此命令将服务器中的所有成员扮演一个角色,但似乎不起作用。它并不是将角色赋予所有成员,而只是给客户。它也没有在控制台中显示任何错误。
@client.command()
async def assignall(ctx, *, role: discord.Role):
await ctx.reply("Attempting to assign all members that role...")
for member in ctx.guild.members:
await member.add_roles(role)
await ctx.reply("I have successfully assigned all members that role!")
I'm trying to give all members in my server a role with this command, but it doesn't seem to work. It doesn't give the role to all the members, but just to the client. It also doesn't show any errors in the console.
@client.command()
async def assignall(ctx, *, role: discord.Role):
await ctx.reply("Attempting to assign all members that role...")
for member in ctx.guild.members:
await member.add_roles(role)
await ctx.reply("I have successfully assigned all members that role!")
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
确保您已经启用了 guild_members' href =“ https://discord.com/developers/applications” rel =“ nofollow noreferrer”> Discord Developer Portal 并以适当的意图初始化了您的客户端。
Ensure that you have enabled the GUILD_MEMBERS Intent from your Discord Developer Portal and initialized your client with the proper intents.
•转到
https://discord.com/developers/applications
•选择bot
•转到“ bot”部分
•向下滚动并启用所有意图(从技术上讲,您只需要服务器成员的意图,但是如果您会做所有的帮助您)
•Go to
https://discord.com/developers/applications
•Select your bot
•Go to the bot section
•Scroll down and enable all the intents(Technically you need only server members' intent but if you do all it will help you)
•Replace your
client=commands.Bot(command_prefix="your_prefix")
to