提问人:XMr_ReaperX 提问时间:11/16/2023 更新时间:11/16/2023 访问量:31
无法通过 Discord 机器人的反应角色添加角色
trouble adding roles through reaction role for my discord bot
问:
所以我试图设置一个反应角色命令,但我得到错误:
*DiscordAPIError: Missing Permissions
at RequestHandler.execute (C:\Users\mreap\Desktop\orbit project, etc\box militia\node_modules\discord.js\src\rest\RequestHandler.js:350:13)
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async RequestHandler.push (C:\Users\mreap\Desktop\orbit project, etc\box militia\node_modules\discord.js\src\rest\RequestHandler.js:51:14)
at async GuildMemberRoleManager.add (C:\Users\mreap\Desktop\orbit project, etc\box militia\node_modules\discord.js\src\managers\GuildMemberRoleManager.js:124:7) {
method: 'put',
path: '/guilds/1015814032088891462/members/1173097778843496620/roles/1015880336665743382',
code: 50013,
httpStatus: 403,
requestData: { json: undefined, files: [] }
}*
我的代码看起来像这样,如果您有任何见解,请帮助我:
const Discord = require('discord.js');
const client = new Discord.Client({ intents: ["GUILDS", "GUILD_MESSAGES", "GUILD_MESSAGE_REACTIONS"] });
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}`);
});
client.on('messageCreate', async (message) => {
if (message.content === '!reaction_role') {
const reactionMessage = await message.channel.send('React to this message to get the role!');
reactionMessage.react('✅');
}
});
client.on('messageReactionAdd', async (reaction, user) => {
if (reaction.emoji.name === '✅') {
const guild = reaction.message.guild;
const member = guild.members.cache.get(user.id);
let role = guild.roles.cache.find(role => role.name === 'test'); // Replace YOUR_ROLE_NAME with the name of the role you want to assign
member.roles.add(role.id);
}
});
client.login('token');
` 我在其他页面上阅读似乎没有任何效果,我重写了我尝试过的所有代码 youtube 反应角色不想为我工作,机器人有权限,它是管理员,机器人角色位于所有其他角色之上
答: 暂无答案
评论
console.log(guild.me.roles.highest.position, member.roles.highest.position)
member.roles.add(role.id)