我制作了一个不和谐机器人,每次有人使用命令时,它都会回复该命令,我试图让它工作,如果我和我的朋友发送命令它不会回复。
我和我的朋友在 discord 上被称为 SugarPancake 和 vordemolt
这是代码:
const Discord = require('discord.js');
const client = new Discord.Client({ partials: ["MESSAGE", "CHANNEL", "REACTION"] });
const prefix = '-';
const fs = require('fs');
client.commands = new Discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file =>
file.endsWith('.js'));
for (const file of commandFiles) {
const command = require(`./commands/${file}`);
client.commands.set(command.name, command);
}
client.once('ready', () => {
console.log('YES is online');
client.user.setActivity(' You Shower', { type: "WATCHING" })
});
client.on('message', message => {
if (!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ +/);
const command = args.shift().toLowerCase();
if (message.author.username == "SugarPancake" || message.author.username ==
"vordemolt" || message.author.username == "malte" || message.author.username ==
"Dr.Garbets") {
if (command === 'comebw') {
client.commands.get('comebw').execute(message, args);
} else if (command == 'come') {
client.commands.get('come').execute(message, args);
}
else if (command == 'mc') {
client.commands.get('mc').execute(message, args);
} else if (command == 'mute') {
console.log(message.author.username);
client.commands.get('mute').execute(message, args);
} else if (command == 'unmute') {
client.commands.get('unmute').execute(message, args);
} else if (command == 'kick') {
client.commands.get('kick').execute(message, args);
}
}
client.on("message", (message) => {
if (message.author.bot || !message.guild) return;
if (message.content.toLowerCase() === ".test") {
if (!message.member.roles.cache.some(r => r.name === "Admin"))
return message.channel.send("You don't have the required role to use this
command!");
const roles = ["Admin"];
if (!message.member.roles.cache.some(r => roles.includes(r.name)))
return message.channel.send("You don't have the required role to use this
command");
}
});
});
client.on("message", async message => {
// white list
var usernames = ["SugarPancake", "vordemolt"];
if (usernames.includes(message.author.username) && message.content.startsWith("-")) {
message.channel.send("We all love SugarPancake and vordemolt");
message.channel.bulkDelete(1);
}
})
这不是所有的代码,还有所有的命令。