Answer the question
In order to leave comments, you need to log in
How to make the bot conditionally send a message in lower case?
Hello. Please help me, I need the bot to send a message according to the condition and not pay attention to the register. BUT be sure to look at the example, otherwise it's hard to explain.
FOR EXAMPLE:
message.content = message.content.lower()
if message.content in ['ghbdtn', 'ghbdtn!', 'ghbdtn)'] :
await message.channel.send(f'>>> **_{ message.author}_ wanted to say: ** Hello!')
await message.delete()
This is a sample code from Python. What is highlighted in bold I need to repeat in JavaScript.
const Discord = require('discord.js')
const client = new Discord.Client()
client.on('ready', () =>{
console.log(`Привет! ${client.user.tag} запустился!`)
})
client.on("message", message => {
if(message.content.toLowerCase()=="ping")
{
message.channel.send(message.author.tag + ", мой пинг равен " + client.ping)
message.delete()
}
})
client.on("message", message => {
if(message.content.toLowerCase()=="pong")
{
message.channel.send(message.author.tag + ", мой понг не равен" + client.ping)
message.delete()
}
})
client.login(token)
Answer the question
In order to leave comments, you need to log in
client.on("message", message => {
if(["one", "two", "three)"].indexOf(message.content.toLowerCase()) !== -1 )
{
message.channel.send("Привет!")
message.delete()
}
})
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question