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 :

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")
        }
    }
}

Leave a Reply