Answer the question
In order to leave comments, you need to log in
How to make the bot determine the names?
Hello. Please help me, I need an array in which I myself will write a lot of names and then the Bot should determine if there is a Name from the array at the beginning of the message, then it should skip this Name and, if possible, translate the rest of the words, and then send a message with the Name + text that it translated. BUT if there is no such Name in the array, then simply do not write the name, but write the translated text. Please excuse me if I didn't explain clearly.
For example: array="Ivan", "Pavel"
User: Vanya hello
Bot: Vanya hello
OR
User: Igor hello
Bot: hello
My code:
const Discord = require('discord.js') // подключение библиотеки
const client = new Discord.Client() // создание клиента
client.on('ready', () =>{ // ивент, когда бот запускается
console.log(`Привет! ${client.user.tag} запустился!`)
})
require('events').EventEmitter.prototype._maxListeners = 70;//лимит ограничений сообщения
require('events').defaultMaxListeners = 70;
process.on('warning', function (err) {
if ( 'MaxListenersExceededWarning' == err.name ) {
console.log('o kurwa');
process.exit(1);
}
});
client.on("message", message => {
if(["ghbdtn", "ghbdtn!", "ghbdtn)"].indexOf(message.content.toLowerCase()) !== -1 )
{
message.channel.send(">>> **_"+message.author.tag+ "_ хотел сказать:** Привет!")
message.delete()
}
})
client.login('token')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question