您如何一次让Discord Server中的每个成员扮演一个角色Discord.py.py

发布于 2025-02-04 22:04:06 字数 389 浏览 3 评论 0原文

我正在尝试通过此命令将服务器中的所有成员扮演一个角色,但似乎不起作用。它并不是将角色赋予所有成员,而只是给客户。它也没有在控制台中显示任何错误。

@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 技术交流群。

扫码二维码加入Web技术交流群

发布评论

需要 登录 才能够评论, 你可以免费 注册 一个本站的账号。

评论(2

独享拥抱 2025-02-11 22:04:06

确保您已经启用了 guild_members' href =“ https://discord.com/developers/applications” rel =“ nofollow noreferrer”> Discord Developer Portal 并以适当的意图初始化了您的客户端。

from discord import Intents
from discord.ext.commands import Bot

client = Bot(intents=Intents.all())

Ensure that you have enabled the GUILD_MEMBERS Intent from your Discord Developer Portal and initialized your client with the proper intents.

from discord import Intents
from discord.ext.commands import Bot

client = Bot(intents=Intents.all())

Server Members Intent

爱殇璃 2025-02-11 22:04:06

•转到https://discord.com/developers/applications

•选择bot

•转到“ bot”部分

•向下滚动并启用所有意图(从技术上讲,您只需要服务器成员的意图,但是如果您会做所有的帮助您)

intents = discord.Intents.default()
intents.message_content = True
client=commands.Bot(command_prefix="your_prefix",intents=intents)

•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)

enter image description here

•Replace your client=commands.Bot(command_prefix="your_prefix") to

intents = discord.Intents.default()
intents.message_content = True
client=commands.Bot(command_prefix="your_prefix",intents=intents)
~没有更多了~
我们使用 Cookies 和其他技术来定制您的体验包括您的登录状态等。通过阅读我们的 隐私政策 了解更多相关信息。 单击 接受 或继续使用网站,即表示您同意使用 Cookies 和您的相关数据。
原文