如何让我的机器人自动删除脏话并将其替换为警告?

时间:2021-01-27 10:59:52

标签: discord discord.js

if (msg.content === 'SWEARWORD') {
    msg.reply('No swearing u nub >:) ');
} 

如何修复它并使其自动删除脏话消息?

1 个答案:

答案 0 :(得分:2)

您应该使用数组来存储您的单词并检查消息的内容是否包含它们:

const words = [ 'bread', 'apple', 'tea' ];
const forbiddenWord = words.some((word) => message.content.includes(word));
if (forbiddenWord ) {
    message.delete();
    message.channel.send('your message should not include : '+forbiddenWord);
}