-2
I’m trying to develop a kind of Mod record for my Discord Bot.
Ps: I do not believe it is necessary knowledge of Discord.js to solve the question
How it would work: The user with administrator permissions would review modstats
, and the bot would return a/embed table with the information of when was the last time a moderator used a command ban/mute/kick/warn
(are already ready) as follows:
warns (última semana): [número]
warns (último mês): [numero]
warns (ano inteiro): [numero]
I was wondering how to get the bot to record the day the last warning was made, and calculate the time interval between the previous one. I thought of something like:
const warn = require('link_do_arquivo_de_warn.js')
const hoje = new Date(); // Data de hoje
const ultimaVez = new Date('2014-07-07'); // Outra data no passado
let calcular = new CalcularIntevaloDeDatas() // função de calcular que eu não faço muita ideia de como montar
if (message.content == warn) //caso algum mod dê um warn
{
db.data.banidos.push(hoje)
db.data.banidos[0] //salva a data de hoje no banco de dados (essa parte não é muito importante. Estou usando um banco chamado LOWDB)
}
if (message.content == "modstats") { return calcular }
console.log(calcular)
But the point is I don’t know how to calculate the difference between the dates saved, I mean, assuming the moderator gave a warn
3 days ago (warn 1), and one day today (warn 2). How do I let the bot know there were 2 Arns a week ago? Then I apply the same logic to the month and year...
Note: In addition to calculating dates, I must also save warn 2 as the last date, and warn 1 as the penultimate (that it is no longer saved as the last date), so I can calculate the next warn from warn 2 - and so on.
This answers your question? Difference between dates
– Vitor Ceolin
It does not answer, because I also need to know how I can save the last date as the last, the last as the penultimate, and so on, automatically....
– Yoazer