I am trying to make a bot that responds randomly when somebody uses the command !say but I want to send some info the first time that somebody uses this command (and then, after the first time, send random messages).
For example:
- (first time)
!say, response: info - (second time)
!say, response: random response - (nth time)
!say, response: random response
I tried to use new Map() so it can keep the ids that executed that command once and then if the map has the id of the message author then send random response.
But the problem is that the bot always responses with "info" and never with random response.
Here is my code
if (!mention) {
message.channel.send("You need to tag someone")
} else {
if (map.has(message.author.id)) {
if (mention.id == message.author.id) {
message.channel.send(random2)
//map.set(message.author.id)
} else if (message.mentions.users.first().bot) {
message.channel.send(random3)
//map.set(message.author.id)
} else {
message.channel.send(random)
//map.set(message.author.id)
}
} else {
message.channel.send("info")
map.set(message.author.id, Date.now())
console.log(map)
}