discord.js-message-replace
v1.0.0
Published
This npm package provides a function to replace words in a message, specifically designed for use in Discord bots.
Downloads
4
Maintainers
Readme
Discord.js Message Replace
This npm package provides a function to replace words in a message, specifically designed for use in Discord bots.
Installation
You can install this package using npm:
npm install discord.js-message-replace
Example
const { replaceWords, replacements } = require('discord.js-message-replace');
const channelsToMonitor = [
"", // channelID
"" // channelID
];
// you can add also too many channels.
client.on('messageCreate', async (message) => {
if (message.author.bot) return; // ignore bots
if (channelsToMonitor.includes(message.channel.id)) {
try {
const replacedContent = replaceWords(message.content, replacements); // replace message & copy it
message.delete() // delete member message
await message.channel.send(`${replacedContent}\n\n||@here||`); // send message after replace.
} catch (error) {
console.error('Error:', error);
}
}
});
Credits
- Developed by AmtiXDev.
License
This project is licensed under the MIT License.