mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-11-17 04:10:59 -05:00
Add top 5 members to yearly nuke.
This commit is contained in:
parent
1cda220a06
commit
18cbc40d79
@ -60,6 +60,10 @@ export class UserLevelsSvc {
|
|||||||
await this.model.update({messages: updatedMessages}, {where: {id: userId}});
|
await this.model.update({messages: updatedMessages}, {where: {id: userId}});
|
||||||
return (await this.model.findByPk(userId)).dataValues;
|
return (await this.model.findByPk(userId)).dataValues;
|
||||||
}
|
}
|
||||||
|
async getActiveUsers() {
|
||||||
|
const members = (await this.model.findAll()).sort((a,b)=>b.dataValues.messages-a.dataValues.messages);
|
||||||
|
return members.slice(0, 5);
|
||||||
|
}
|
||||||
async messageIncremental(userId:string) {
|
async messageIncremental(userId:string) {
|
||||||
const data = await this.model.findByPk(userId);
|
const data = await this.model.findByPk(userId);
|
||||||
if (data) {
|
if (data) {
|
||||||
@ -82,19 +86,27 @@ export class UserLevelsSvc {
|
|||||||
cron.schedule('0 11 1 1 *', async()=>{
|
cron.schedule('0 11 1 1 *', async()=>{
|
||||||
Logger.console('log', 'Cron', 'Running job "resetAllData", this is activated every 1st of January');
|
Logger.console('log', 'Cron', 'Running job "resetAllData", this is activated every 1st of January');
|
||||||
const performCountBeforeReset = await this.model.count();
|
const performCountBeforeReset = await this.model.count();
|
||||||
|
const topMembers = await this.getActiveUsers();
|
||||||
|
|
||||||
Logger.console('log', 'Cron:resetAllData', `Counted ${performCountBeforeReset.toLocaleString()} members before reset`);
|
Logger.console('log', 'Cron:resetAllData', `Counted ${performCountBeforeReset.toLocaleString()} members before reset`);
|
||||||
await this.client.dailyMsgs.nukeDays();
|
await this.client.dailyMsgs.nukeDays();
|
||||||
await this.model.drop().then(async()=>await this.model.sync());
|
await this.model.drop().then(async()=>await this.model.sync());
|
||||||
|
|
||||||
|
try {
|
||||||
// Send notification to dcServer's logs channel after cronjob is complete.
|
// Send notification to dcServer's logs channel after cronjob is complete.
|
||||||
(this.client.channels.resolve(this.client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [new this.client.embed()
|
(this.client.channels.resolve(this.client.config.dcServer.channels.logs) as Discord.TextChannel).send({embeds: [new this.client.embed()
|
||||||
.setColor('#A3FFE3')
|
.setColor('#A3FFE3')
|
||||||
.setTitle('Yearly data reset has begun!')
|
.setTitle('Yearly data reset has begun!')
|
||||||
.setDescription(MessageTool.concatMessage(
|
.setDescription(MessageTool.concatMessage(
|
||||||
'I have gone ahead and reset everyone\'s rank data.',
|
'I have gone ahead and reset everyone\'s rank data.',
|
||||||
`There was ${Intl.NumberFormat('en-US').format(performCountBeforeReset)} members in database before reset.`
|
`There was ${Intl.NumberFormat('en-US').format(performCountBeforeReset)} members in database before reset.\n`,
|
||||||
|
'Top 5 most active members:',
|
||||||
|
...topMembers.map((m,i)=>`${i+1}. **${(this.client.users.resolve(m.dataValues.id) ? this.client.users.resolve(m.dataValues.id).displayName : '*Unknown User*')}** - **${m.dataValues.messages.toLocaleString()}** messages`)
|
||||||
))
|
))
|
||||||
]});
|
]});
|
||||||
|
} catch (why) {
|
||||||
|
Logger.console('error', 'Cron:resetAllData:DEBUG', why)
|
||||||
|
}
|
||||||
|
|
||||||
// Reset LRSstart to current Epoch and save it to config file
|
// Reset LRSstart to current Epoch and save it to config file
|
||||||
const newEpoch = new Date().getTime();
|
const newEpoch = new Date().getTime();
|
||||||
|
Loading…
Reference in New Issue
Block a user