Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

How to make the Bot only work in specific channels?

I opened 2 channels, profanity is allowed in 1 channel, the other will be prohibited, but when the bot deletes the messages in both channels when swearing in 2 channels, how can I do this in 1 channel, for example, there are chat1 and chat2, the bot can only delete the messages in chat1.


client.on('message', message => {
    if (message.content.toLowerCase().includes('.ad')){
        message.delete()
        message.reply("orosbu evladı ananı sikmeden ticketden kullan komutu chata birdaha yazarsan banlancan")
    }
}
)

I opened 2 channels, profanity is allowed in 1 channel, the other will be prohibited, but when the bot deletes the messages in both channels when swearing in 2 channels, how can I do this in 1 channel, for example, there are chat1 and chat2, the bot can only delete the messages in chat1.


--------


client.on('message', message => {
    if (message.content.toLowerCase().includes('.ad')){
        message.delete()
        message.reply("orosbu evladı ananı sikmeden ticketden kullan komutu chata birdaha yazarsan banlancan")
    }

>Solution :

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

As seen here you can check the message channel id against the id of the channel that you want the bot to operate on.

The general code would be:

const disallowProfanityChannelID= '0123456789'

client.on('message', message => {
    if(message.channel.id === disallowProfanityChannelID) {
       block_profanity();
    }
});

For your specific use case:

client.on('message', message => {
    if(message.channel.id === disallowProfanityChannelID) {
        if (message.content.toLowerCase().includes('.ad')){
            message.delete()
            message.reply("orosbu evladı ananı sikmeden ticketden kullan komutu chata birdaha yazarsan banlancan")
        }
    }
}
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading