Discord.js角色反应

时间:2020-08-16 01:49:46

标签: node.js discord.js

运行此命令会给出错误消息。 该机器人对该服务器进行全面的管理员管理。

client.on('messageReactionAdd', async (reaction, user) => {
    if (reaction.message.partial); await reaction.message.fetch();
    if (reaction.partial) await reaction.fetch();

    if (user.bot) return;
    if (!reaction.message.guild) return;

    if ((reaction.message.channel.id === "744212634446224976") && (reaction.emoji.name === '?')) {
            reaction.message.guild.members.cache.get(user.id).roles.add('746263081695067178').catch()
    }
});

错误消息:

(node:17644) UnhandledPromiseRejectionWarning: DiscordAPIError: Missing Permissions
    at RequestHandler.execute (D:\Projects\Bot-role\node_modules\discord.js\src\rest\RequestHandler.js:170:25)
    at processTicksAndRejections (internal/process/task_queues.js:97:5)
(node:17644) UnhandledPromiseRejectionWarning: Unhandled promise rejection. This error originated either by throwing inside of an async function without a catch block, or by rejecting a promise which was not handled with .catch(). To terminate the node process on unhandled promise rejection, use the CLI flag `--unhandled-rejections=strict` (see https://nodejs.org/api/cli.html#cli_unhandled_rejections_mode). (rejection id: 1)
(node:17644) [DEP0018] DeprecationWarning: Unhandled promise rejections are deprecated. In the future, promise rejections that are not handled will terminate the Node.js process with a non-zero exit code.

1 个答案:

答案 0 :(得分:0)

要更改的角色必须在客户端(机器人)自己的角色下。
在[服务器]>服务器设置>角色

下更改顺序