mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-27 04:15:38 -05:00
Add statsGraph command and use fs instead of require
This commit is contained in:
parent
cf0f4642b7
commit
a43c659ffc
@ -39,6 +39,7 @@ export class TClient extends Client {
|
||||
bonkCount: bonkCount;
|
||||
bannedWords: bannedWords;
|
||||
repeatedMessages: any;
|
||||
statsGraph: number;
|
||||
|
||||
constructor(){
|
||||
super({
|
||||
@ -76,7 +77,8 @@ export class TClient extends Client {
|
||||
this.punishments = new punishments(this);
|
||||
this.bannedWords = new bannedWords(this);
|
||||
this.repeatedMessages = {};
|
||||
this.setMaxListeners(80)
|
||||
this.setMaxListeners(80);
|
||||
this.statsGraph = -60;
|
||||
}
|
||||
async init(){
|
||||
MPDB.sync();
|
||||
|
@ -2,6 +2,8 @@ import Discord,{SlashCommandBuilder} from 'discord.js';
|
||||
import { TClient } from 'src/client';
|
||||
import * as util from 'node:util';
|
||||
import {exec} from 'node:child_process';
|
||||
import { readFileSync } from 'node:fs';
|
||||
import path from 'node:path';
|
||||
const removeUsername = (text: string)=>{
|
||||
let matchesLeft = true;
|
||||
const array = text.split('\\');
|
||||
@ -77,6 +79,10 @@ export default {
|
||||
}
|
||||
});
|
||||
break
|
||||
case 'statsgraph':
|
||||
client.statsGraph = -(interaction.options.getInteger('number', true))
|
||||
interaction.reply(`Successfully set to \`${client.statsGraph}\`\n*Total data points: **${JSON.parse(readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).length.toLocaleString()}***`);
|
||||
break
|
||||
}
|
||||
},
|
||||
data: new SlashCommandBuilder()
|
||||
@ -98,4 +104,11 @@ export default {
|
||||
.addSubcommand((optt)=>optt
|
||||
.setName('update')
|
||||
.setDescription('Pull from repository and restart'))
|
||||
.addSubcommand((optt)=>optt
|
||||
.setName('statsgraph')
|
||||
.setDescription('Edit the number of data points to pull')
|
||||
.addIntegerOption((hiTae)=>hiTae
|
||||
.setName('number')
|
||||
.setDescription('Number of data points to pull')
|
||||
.setRequired(true)))
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ export default {
|
||||
break;
|
||||
case 'players':
|
||||
const embed1 = new client.embed();
|
||||
const data = JSON.parse(fs.readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).slice(-60)
|
||||
const data = JSON.parse(fs.readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).slice(client.statsGraph)
|
||||
|
||||
// handle negative days
|
||||
data.forEach((change: number, i: number) => {
|
||||
|
@ -117,9 +117,9 @@ setInterval(async()=>{
|
||||
return;
|
||||
}
|
||||
|
||||
const DB = require(`./database/MPPlayerData.json`);
|
||||
const DB = JSON.parse(fs.readFileSync(__dirname + '/database/MPPlayerData.json', {encoding: 'utf8'}));
|
||||
DB.push(FSdss.data.slots.used)
|
||||
fs.writeFileSync(__dirname + `/database/MPPlayerData.json`, JSON.stringify(DB))
|
||||
fs.writeFileSync(__dirname + '/database/MPPlayerData.json', JSON.stringify(DB))
|
||||
|
||||
// Number format function
|
||||
function formatNumber(number: any, digits: any, icon: any){
|
||||
|
Loading…
Reference in New Issue
Block a user