if(message.content.toLowerCase().includes("word")) {
let badMsg = message.content;
let badMsgChan = message.guild.channels.cache.get(message.channel.id);
let badMsgUser = message.author;
let logChan = message.guild.channels.cache.find(ch => ch.name === "logs");
let emb = new Discord.MessageEmbed()
.setTitle("Blacklisted word used")
.addField("Content", badMsg, true)
.addField("Found in", badMsgChan, true)
.addField("Written by", badMsgUser, true)
.setTimestamp()
logChan.send(emb);
message.delete();
message.reply("don't send that word here.");
}
I would recommend using .includes()
instead of ===
, because ===
means it has to be exactly that value (word). .includes()
checks if the value (word) is included in the message content.
So I've created some variables that store the information about that "bad" message. badMsg
is storing the message content (the sentence or whatever the word was included in). badMsgChan
stores the channel, the "bad" message was found in. badMsgUser
stores the user who has sent the "bad" message. And logChan
is the channel where you want to send the embed in. You can change everything exactly in your style, I just wanted to give an example of how you could solve your problem. So the embed has 3 fields with:
Content
-> The "bad" message content.
Found in
-> The Channel where the "bad" message was found in.
Written by
-> The user who sent the message.
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…