Discord Bot设置某人的昵称

时间:2019-03-05 05:11:31

标签: javascript node.js bots discord discord.js

我正在尝试创建Discord机器人,并且想要执行!nick命令,但我仍然遇到相同的错误,有人可以帮助我吗?

错误:

{ DiscordAPIError: Missing Permissions

    at item.request.gen.end (/rbd/pnpm-volume/76d7cd6d-9602-4908-bb55-ccc4f8de8537/node_modules/.registry.npmjs.org/discord.js/11.4.2/node_modules/discord.js/src/client/rest/RequestHandlers/Sequential.js:79:15)

    at then (/rbd/pnpm-volume/76d7cd6d-9602-4908-bb55-ccc4f8de8537/node_modules/.registry.npmjs.org/snekfetch/3.6.4/node_modules/snekfetch/src/index.js:215:21)

    at <anonymous>

    at process._tickCallback (internal/process/next_tick.js:189:7)

  name: 'DiscordAPIError',

  message: 'Missing Permissions',

  path: '/api/v7/guilds/485921672013283339/members/469227202345697280',

  code: 50013,

  method: 'PATCH' }
码:
const Discord = require("discord.js");

exports.run = (client, message, args, member) => {
  const arg = args.join(" ")
  if (arg === null || arg === "" || arg === undefined || arg == " ") {
    var embed = new Discord.RichEmbed()
      embed.setColor(0x00AE86);
      embed.addField("USAGE", "!nick (nickname)", false);
    message.channel.send(embed);
  }
  else {
    var embed = new Discord.RichEmbed()
      embed.setColor(0x00AE86);
      embed.addField("NICKNAME", "You have set your nickname to **" + arg + "**", false);
    message.channel.send(embed);
    message.member.setNickname("["+ member.highestRole.name + "]" + member.displayName)
      .then(console.log)
      .catch(console.error);
}
}

有人知道我为什么收到此错误,如果是这样,请告诉我如何进行修复。谢谢!

1 个答案:

答案 0 :(得分:1)

message: 'Missing Permissions'中我们可以得出结论,您的漫游器缺少必需的权限。

要解决此问题,请访问Discord开发人员门户并获取包含所需权限的PERMISSIONS INTEGER。最常见的是8,它是管理员权限的整数。

如果这样不起作用,请确保您的机器人角色在Discord Server中处于其他角色之上 as shown here