gpt4 book ai didi

javascript - Discord Bot 设置某人的昵称

转载 作者:行者123 更新时间:2023-12-03 00:05:04 29 4
gpt4 key购买 nike

我正在尝试制作一个 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);
}
}

有谁知道我为什么会收到此错误,如果是,请告诉我如何修复它。谢谢!

最佳答案

根据消息:“缺少权限”,我们可以得出结论:您的机器人缺少所需的权限。

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

如果这不起作用,请确保您的机器人在 Discord 服务器中的 Angular 色高于其他机器人 as shown here

关于javascript - Discord Bot 设置某人的昵称,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/54995805/

29 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com