是否可以禁用人们在 discord 机器人上使用"say"命令对@everyone和@here执行 ping 操作?



我尝试了一些方法来阻止人们对每个人进行ping,但我想要的是如果消息中有"每个人";或"@这里";我可以让机器人以几种不同的方式回复

这是我当前的代码

const Discord = require ('discord.js');
const { FILE } = require('dns');
const client = new Discord.Client();
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('IM ONLINE GUYS!!!');
});
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(command === 'ping'){
client.commands.get('ping').execute(message, args);
} else if (command == 'pong'){
client.commands.get('pong').execute(message, args);
} else if (command == 'help'){
client.commands.get('help').execute(message, args, Discord);
} else if (command == 'kill'){
client.commands.get('kill').execute(message, args);
} else if (command == 'quote'){
client.commands.get('quote').execute(message, args);
} else if (command == 'kiss'){
client.commands.get('kiss').execute(message, args);
} else if (command == 'hug'){
client.commands.get('hug').execute(message, args);
} else if (command == 'pet'){
client.commands.get('pet').execute(message, args);   
} else if (command === 'say'){
const sayMessage = message.content.split(' ').slice(1).join(' ');
message.channel.send(sayMessage);
} else if (command === 'music-h'){
client.commands.get('music-h').execute(message, args, Discord)
}
})
client.login('token')

我指的是

} else if (command === 'say'){
const sayMessage = message.content.split(' ').slice(1).join(' ');
message.channel.send(sayMessage);

部分

我将在这里更好地解释:当有人在他们的"中ping到@everyone或@here时,我试图让机器人用其他东西来回应;。比如";消息

示例:

&";。说"每个人";

"不错的尝试,伙计,这对我不起作用;

也许还有其他一些回应。

当然可以!

if (message.content.includes('@everyone') || message.content.includes('@here')) {
message.channel.send('Nice try bub, its not gonna work with me')

如果你需要进一步的帮助,请告诉我,干杯!

最新更新