【发布时间】:2020-09-22 23:38:54
【问题描述】:
我的Discord.js kick 命令有问题。
我的代码:
const Discord = require('discord.js');
const { prefix, token } = require('../config.json');
module.exports = {
name: 'kick',
description: 'kick users',
execute(message, args) {
if (!message.member.hasPermission('KICK_MEMBERS')) {
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You are not allowed to use this command.`,
footer: {
text: ` | Required permission: KICK_MEMBERS`,
},
},
});
}
if (!message.guild.me.permissions.has('KICK_MEMBERS')) {
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, I am not allowed to use this command.`,
footer: {
text: ` | Required permission: KICK_MEMBERS`,
},
},
});
}
if (!args[0]) {
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You need to mention a user first.`,
footer: {
text: ` | Example: !kick @Bot`,
},
},
});
}
const member =
message.mentions.members.first() || message.guild.members.cache.get(args[0]);
if (member.user.id === message.author.id) {
return message.channel.send({
embed: {
color: 16777201,
description: `:x: | ${message.author}, You cannot expel yourself.`,
footer: {
text: ` | Example: !kick @Bot`,
},
},
});
}
try {
member.kick();
message.channel.send(`${member} has been kicked!`);
} catch (e) {
return message.channel.send(`User isn't in this server!`);
}
},
};
忽略不完整的代码,我还在考虑嵌入的设计!
我正在尝试做 3 件事:
-
如果有人试图通过提及机器人来使用该命令,他们会说“你不能这样做”
-
我想要的另一件事是用户不可能踢他上方的人
-
我希望会员被踢,你必须做出是或否的反应
【问题讨论】:
标签: javascript node.js discord discord.js