我做了一个添加角色命令并为其添加了权限。但是,在运行命令时出现错误。这是我的代码:
String customers = "\'xxx\',\'zzz\',\'yyy\'";
Map<String, Object> parameter = new HashMap<>();
parameter.put("customers", customers);
正如我之前提到的,我得到一个错误:
const { MessageEmbed } = require('discord.js');
module.exports = {
name: "addrole",
aliases: ["ar"],
description: "Adds a role to a user",
async execute(client, message, args) {
if (!message.member.hasPermission('MANAGE_ROLES')) return message.channel.send('NO PERMS')
if (!message.guild.me.hasPermission('MANAGE_ROLES')) return message.channel.send('NO PERMS')
const member = message.guild.members.cache.get(args[0]);
if (!member)
return message.channel.send('Please mention a user or provide a valid user ID');
if (member.roles.highest.position >= message.member.roles.highest.position)
return message.channel.send('You cannot add a role to someone with an equal or higher role');
const role = message.guild.roles.cache.get(args[1]);
let reason = args.slice(2).join(' ');
if (!reason) reason = '`None`';
if (reason.length > 1024) reason = reason.slice(0, 1021) + '...';
if (!role)
return message.channel.send('Please mention a role or provide a valid role ID');
else if (member.roles.cache.has(role.id)) // If member already has role
return message.channel.send('User already has the provided role');
else {
try {
// Add role
await member.roles.add(role);
const embed = new MessageEmbed()
.setTitle('Add Role')
.setDescription(`${role} was successfully added to ${member}.`)
.addField('Moderator', message.member, true)
.addField('Member', member, true)
.addField('Role', role, true)
.addField('Reason', reason)
.setFooter(message.member.displayName, message.author.displayAvatarURL({ dynamic: true }))
.setTimestamp()
.setColor(message.guild.me.displayHexColor);
message.channel.send(embed);
} catch (err) {
return message.channel.send('Please check the role hierarchy or if the role is managed by an integeration or system', err.message);
}
}
}
}
我在每个命令中都使用了相同的权限代码,但是第一次出现此错误。你能帮我吗?预先感谢