I have made a Discord bot and I want it to be able to check the current date, and if current date is any of the users birthday, then it'll tag them and say happy birthday. I have tried using Node.js' Date, like
if(Date === "this or that")
but that didn't seem to work. So what I need help with is:
- Checking the current date (like run a check each day or something)
- send a message at that current date
I'll probably just hardcode all the birthdays in since we're not that many (I know that's not good practice, but I just want it working for now, I can polish it later)
If anyone could help me with that, that'd be great.
This is what my index.js file looks like (if that is relevant):
const discord = require("discord.js");
const config = require("./config.json");
const client = new discord.Client();
const prefix = '>';
const fs = require('fs');
const { time, debug } = require("console");
client.commands = new discord.Collection();
const commandFiles = fs.readdirSync('./commands/').filter(file => file.endsWith('.js'));
for(const file of commandFiles)
{
const command = require(`./commands/${file}`)
client.commands.set(command.name, command);
}
client.once('ready', () =>
{
console.log(`${client.user.username} is online`);
})
client.on('message', message =>
{
if(!message.content.startsWith(prefix) || message.author.bot) return;
const args = message.content.slice(prefix.length).split(/ + /);
const command = args.shift().toLowerCase();
if(command === 'ping')
{
client.commands.get('ping').execute(message, args);
}else if(command === 'wololo')
{
client.commands.get('wololo').execute(message, args);
}
})
client.login('TOKEN')
Edit:
I realise I wrote the "if(date)" statement in "client.on('message',message =>{})", so that obviously wouldn't check unless you wrote a command at that specific time. What function would I use?