这是 kick.js 文件
module.exports = function (msg, args) {
name: 'kick',
description = 'Kick members',
execute(client, msg, args);
if (msg.member.permissions.has('KICK_MEMBERS')) {
if (args.length === 0) {
msg.channel.send('Please specify a person');
return;
}
if (args.length === 1) {
msg.channel.send('Please specify a reason');
return;
}
let reason = "";
for (i in args - 1) {
reason += args[i + 1] + ' ';
}
const member = msg.mentions.users.first();
if (member) {
const target = msg.guild.members.cache.get(member.id);
target.kick(reason);
msg.channel.send("**User has been kicked**");
} else {
msg.channel.send("**You couldn't kick that member.**");
}
} else {
msg.channel.send('You do not have the permission to kick members. Please contact staff for help.');
}
}
和 command.js 文件:
const gif = require('./commands/fun/gif.js');
const chillutils = require('./commands/fun/chillutils.js');
const ban = require('./commands/moderation/ban.js');
const kick = require('./commands/moderation/kick.js')
const commands = { chillutils, gif, ban, kick };
module.exports = async function (msg) {
if (msg.channel.id == '799637023241404456') {
let tokens = msg.content.split(' ');
let command = tokens.shift();
if (command.charAt(0) === '!') {
command = command.substring(1);
commands[command](msg, tokens);
}
}
};
这是针对 dsicord 机器人的。我试过问我的朋友,他们也不知道。我正在使用使用 node.js 和 discord.js 的 vscode。当在通道中输入命令时,在终端中它只是说“未定义执行”,我不知道在哪里或如何修复它。