discord.js-message-replace

1.0.0 • Public • Published

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

License

This project is licensed under the MIT License.

Package Sidebar

Install

npm i discord.js-message-replace

Weekly Downloads

1

Version

1.0.0

License

MIT

Unpacked Size

2.75 kB

Total Files

3

Last publish

Collaborators

  • amtixdev