1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-12-27 04:15:38 -05:00

Turning the bot back to JS.

This commit is contained in:
AnxietyisReal 2023-04-14 20:47:58 +10:00
parent 245e69a443
commit 5f457c2604
45 changed files with 111 additions and 105 deletions

1
.gitignore vendored
View File

@ -4,6 +4,7 @@ node_modules/
package-lock.json
.ncurc.json
# Bot stuff
dist/
src/database/
src/tokens.json
src/Toast-Testbot.config.json

View File

@ -1,7 +1,8 @@
{
"name": "daggerbot-ts",
"description": "TypeScript version of the original JavaScript-based bot for Official Daggerwin Discord.",
"main": "src/index.ts",
"main": "dist/index.js",
"type": "module",
"repository": {
"type": "git",
"url": "git+https://github.com/AnxietyisReal/Daggerbot-TS.git"
@ -35,6 +36,7 @@
"xml-js": "1.6.11"
},
"devDependencies": {
"@types/ms": "0.7.31",
"@types/node": "18.15.11",
"ts-node": "10.9.1"
}

View File

@ -1,27 +1,26 @@
import Discord, { Client, WebhookClient, GatewayIntentBits, Partials } from 'discord.js';
import fs from 'node:fs';
import { exec } from 'node:child_process';
import timeNames from './timeNames';
import {exec} from 'node:child_process';
import timeNames from './timeNames.js';
import mongoose from 'mongoose';
import { formatTimeOpt, Tokens, Config, repeatedMessages } from './typings/interfaces';
import bannedWords from './models/bannedWords';
import userLevels from './models/userLevels';
import suggestion from './models/suggestion';
import punishments from './models/punishments';
import bonkCount from './models/bonkCount';
import MPServer from './models/MPServer';
import {formatTimeOpt, Tokens, Config, repeatedMessages} from './typings/interfaces';
import bannedWords from './models/bannedWords.js';
import userLevels from './models/userLevels.js';
import suggestion from './models/suggestion.js';
import punishments from './models/punishments.js';
import bonkCount from './models/bonkCount.js';
import MPServer from './models/MPServer.js';
import xjs from 'xml-js';
import axios from 'axios';
import moment from 'moment';
import tokens from './tokens.json';
import tokens from './tokens.json' assert { type: 'json'};
let importconfig:Config
try{
importconfig = require('./DB-Beta.config.json')
importconfig = JSON.parse(fs.readFileSync('src/DB-Beta.config.json', {encoding:'utf8'}));
console.log('Using development config :: Daggerbot Beta')
//importconfig = require('./Toast-Testbot.config.json')
//console.log('Using development config :: Toast-Testbot')
} catch(e){
importconfig = require('./config.json')
importconfig = JSON.parse(fs.readFileSync('src/config.json', {encoding:'utf8'}))
console.log('Using production config')
}
@ -37,7 +36,7 @@ export default class TClient extends Client {
messageCollector: any;
attachmentBuilder: any;
moment: typeof moment;
xjs: any;
xjs: typeof xjs;
axios: typeof axios;
ms: any;
userLevels: userLevels;
@ -77,9 +76,9 @@ export default class TClient extends Client {
this.messageCollector = Discord.MessageCollector;
this.attachmentBuilder = Discord.AttachmentBuilder;
this.moment = moment;
this.xjs = require('xml-js');
this.xjs = xjs;
this.axios = axios;
this.ms = require('ms');
this.ms = import('ms').then(i=>i);
this.userLevels = new userLevels(this);
this.bonkCount = new bonkCount(this);
this.punishments = new punishments(this);
@ -102,17 +101,17 @@ export default class TClient extends Client {
socketTimeoutMS: 30000,
family: 4
}).then(()=>console.log(this.logTime(), 'Successfully connected to MongoDB')).catch((err)=>{console.error(this.logTime(), `Failed to connect to MongoDB\n${err.reason}`); exec('pm2 stop Daggerbot')})
await this.login(this.tokens.main);
const commandFiles = fs.readdirSync('src/commands').filter(file=>file.endsWith('.ts'));
await this.login(this.tokens.beta);
fs.readdirSync('dist/events').forEach(async file=>{
const eventFile = await import(`./events/${file}`);
this.on(file.replace('.js', ''), async(...args)=>eventFile.default.run(this,...args));
});
const commandFiles = fs.readdirSync('dist/commands').filter(file=>file.endsWith('.js'));
for (const file of commandFiles){
const command = require(`./commands/${file}`);
this.commands.set(command.default.data.name, command)
const command = await import(`./commands/${file}`);
this.commands.set(command.default.data.name, {command, uses: 0})
this.registry.push(command.default.data.toJSON())
}
fs.readdirSync('src/events').forEach((file)=>{
const eventFile = require(`./events/${file}`);
this.on(file.replace('.ts', ''), async(...args)=>eventFile.default.run(this,...args));
});
}
formatTime(integer: number, accuracy = 1, options?: formatTimeOpt){
let achievedAccuracy = 0;
@ -170,7 +169,7 @@ export default class TClient extends Client {
let error;
try {
await this.axios.get(`https://www.youtube.com/feeds/videos.xml?channel_id=${YTChannelID}`, {timeout: 5000}).then((xml:any)=>Data = this.xjs.xml2js(xml.data, {compact: true, spaces: 2}))
await this.axios.get(`https://www.youtube.com/feeds/videos.xml?channel_id=${YTChannelID}`, {timeout: 5000}).then((xml:any)=>Data = this.xjs.xml2js(xml.data, {compact: true}))
} catch(err){
error = true;
console.log(this.logTime(), `${YTChannelName} YT fail`)
@ -194,6 +193,7 @@ export class WClient extends WebhookClient {
super({
url: tokens.webhook_url
})
this.tokens = tokens as Tokens;
}
}
// hi tae, ik you went to look for secret hello msgs in here too.

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'ban');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
import {writeFileSync} from 'node:fs';
import path from 'node:path';
export default {

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
//if (!client.isStaff(interaction.member) && interaction.channelId == '468835415093411863') return interaction.reply('This command is restricted to staff only in this channel due to high usage.')

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from "discord.js";
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.isStaff(interaction.member)) return client.youNeedRole(interaction, 'dcmod');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
interaction.reply({embeds: [new client.embed().setColor(client.config.embedColor).setTitle('Daggerbot contributors').setDescription([

View File

@ -1,9 +1,9 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import {Octokit} from '@octokit/rest';
import {exec} from 'node:child_process';
import {readFileSync} from 'node:fs';
import fs from 'node:fs';
import util from 'node:util';
import TClient from '../client';
import TClient from '../client.js';
import path from 'node:path';
const removeUsername = (text: string)=>{
let matchesLeft = true;
@ -100,7 +100,7 @@ export default {
},
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()}***`)
interaction.reply(`Successfully set to \`${client.statsGraph}\`\n*Total data points: **${JSON.parse(fs.readFileSync(path.join(__dirname, '../database/MPPlayerData.json'), {encoding: 'utf8'})).length.toLocaleString()}***`)
},
logs: ()=>{
interaction.deferReply();

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
({

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'kick');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
import path from 'node:path';
import canvas from 'canvas';
import fs from 'node:fs';

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'mute');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
const msg = await interaction.reply({content: 'Pinging...', fetchReply: true})

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.isStaff(interaction.member)) return client.youNeedRole(interaction, 'dcmod');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
const embed = new client.embed().setColor(Math.floor(Math.random()*16777215));

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
import path from 'node:path';
import fs from 'node:fs';
import canvas from 'canvas';
@ -30,7 +30,7 @@ export default {
const messageCountsTotal = allData.reduce((a, b) => a + b.messages, 0);
const timeActive = Math.floor((Date.now() - client.config.LRSstart)/1000/60/60/24);
const dailyMsgsPath = path.join(__dirname, '../database/dailyMsgs.json');
const dailyMsgsPath = path.join('./src/database/dailyMsgs.json');
const data = JSON.parse(fs.readFileSync(dailyMsgsPath, 'utf8')).map((x: Array<number>, i: number, a: any) => {
const yesterday = a[i - 1] || [];
return x[1] - (yesterday[1] || x[1]);

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
const role = interaction.options.getRole('role') as Discord.Role;

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'softban');

View File

@ -1,7 +1,7 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import {version} from 'typescript';
import pkg from 'typescript';
import si from 'systeminformation';
import TClient from 'src/client';
import TClient from '../client.js';
import os from 'node:os';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
@ -15,7 +15,7 @@ export default {
const i = Math.floor(Math.log(bytes) / Math.log(k));
return parseFloat((bytes / Math.pow(k, i)).toFixed(dm)) + ' ' + sizes[i];
};
var DJSver = require('discord.js').version;
var DJSver = (await import('discord.js')).version;
const cpu = await si.cpu();
const ram = await si.mem();
const osInfo = await si.osInfo();
@ -25,11 +25,11 @@ export default {
const columns = ['Command name', 'Count'];
const includedCommands = client.commands.filter(x=>x.uses).sort((a,b)=>b.uses - a.uses);
if (includedCommands.size == 0) return interaction.reply(`No commands have been used yet.\nUptime: **${client.formatTime(client.uptime as number, 3, {longNames: true, commas: true})}**`);
const nameLength = Math.max(...includedCommands.map(x=>x.default.data.name.length), columns[0].length) + 2;
const nameLength = Math.max(...includedCommands.map(x=>x.command.default.data.name.length), columns[0].length) + 2;
const amountLength = Math.max(...includedCommands.map(x=>x.uses.toString().length), columns[1].length) + 1;
const rows = [`${columns[0] + ' '.repeat(nameLength - columns[0].length)}|${' '.repeat(amountLength - columns[1].length) + columns[1]}\n`, '-'.repeat(nameLength) + '-'.repeat(amountLength) + '\n'];
includedCommands.forEach(command=>{
const name = command.default.data.name;
const name = command.command.default.data.name;
const count = command.uses.toString();
rows.push(`${name + ' '.repeat(nameLength - name.length)}${' '.repeat(amountLength - count.length) + count}\n`);
});
@ -50,7 +50,7 @@ export default {
} else embed.addFields({name: '\u200b', value: `\`\`\`\n${rows.join('')}\`\`\``});
embed.addFields(
{name: '> __Dependencies__', value: [
`**TypeScript:** ${version}`,
`**TypeScript:** ${pkg.version}`,
`**NodeJS:** ${process.version}`,
`**DiscordJS:** ${DJSver}`,
`**Axios:** ${client.axios.VERSION}`
@ -64,7 +64,7 @@ export default {
`**Uptime:**\nHost: ${client.formatTime((os.uptime()*1000), 2, {longNames: true, commas: true})}\nBot: ${client.formatTime(client.uptime as number, 2, {commas: true, longNames: true})}`
].join('\n')}
);
interaction.reply({embeds: [embed], fetchReply: true}).then((x)=>x.edit({embeds: [new client.embed(x.embeds[0].data).setFooter({text: `Load time: ${client.formatTime(x.createdTimestamp - interaction.createdTimestamp, 2, {longNames: true, commas: true})}`})]}))
interaction.reply({embeds: [embed], fetchReply: true}).then(x=>x.edit({embeds: [new client.embed(x.embeds[0].data).setFooter({text: `Load time: ${client.formatTime(x.createdTimestamp - interaction.createdTimestamp, 2, {longNames: true, commas: true})}`})]}))
},
data: new SlashCommandBuilder()// Nice
.setName('statistics')

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient,{WClient} from '../client';
import TClient,{WClient} from '../client.js';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
const replyInDM = interaction.options.getString('message');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
async run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
if (!client.isStaff(interaction.member as Discord.GuildMember)) return client.youNeedRole(interaction, 'dcmod');

View File

@ -1,5 +1,5 @@
import Discord,{SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
export default {
run(client: TClient, interaction: Discord.ChatInputCommandInteraction<'cached'>){
client.punish(client, interaction, 'warn');

View File

@ -1,5 +1,5 @@
import Discord,{GuildMember, SlashCommandBuilder} from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
function convert(status?:Discord.ClientPresenceStatus){
if (status) return {

View File

@ -20,9 +20,9 @@
},
"botPresence": {
"activities": [
{"name": "the audio", "url": "https://www.youtube.com/watch?v=HQnC1UHBvWA", "type": 1}
{"name": "the server", "url": "https://www.youtube.com/watch?v=1P17ct4e5OE", "type": 1}
],
"status": "idle"
"status": "online"
},
"eval": {
"allowed": true,

View File

@ -1,5 +1,5 @@
import Discord, { AuditLogEvent } from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
async run(client:TClient, member:Discord.GuildMember){
if (member.guild?.id != client.config.mainServer.id) return;

View File

@ -1,5 +1,5 @@
import Discord, { AuditLogEvent } from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
async run(client:TClient, member:Discord.GuildMember){
if (member.guild?.id != client.config.mainServer.id) return;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
async run(client:TClient, member:Discord.GuildMember){
if (member.partial || member.guild?.id != client.config.mainServer.id) return;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
async run(client:TClient, member:Discord.GuildMember){
if (!client.config.botSwitches.logs) return;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
run(client:TClient, oldMember:Discord.GuildMember, newMember:Discord.GuildMember){
if (oldMember.guild.id != client.config.mainServer.id) return;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
run(client:TClient, interaction:Discord.BaseInteraction){
if (!interaction.inGuild() || !interaction.inCachedGuild()) return;
@ -9,7 +9,7 @@ export default {
if (!client.config.botSwitches.commands && !client.config.eval.whitelist.includes(interaction.user.id)) return interaction.reply({content: 'Bot is currently being run in development mode.', ephemeral: true});
if (commandFile){
try{
commandFile.default.run(client, interaction);
commandFile.command.default.run(client, interaction);
commandFile.uses ? commandFile.uses++ : commandFile.uses = 1;
} catch (error){
console.log(`An error occurred while running command "${interaction.commandName} ${interaction.options.getSubcommand(false) ?? ''}"`, error, error.stack);

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
async run(client:TClient, invite: Discord.Invite){
if (!invite.guild) return;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
run(client:TClient, invite: Discord.Invite){
client.invites.delete(invite.code)

View File

@ -1,8 +1,8 @@
import Discord, { ChannelType } from 'discord.js';
import TClient from '../client';
import Discord from 'discord.js';
import TClient from 'src/client';
export default {
async run(client:TClient, message:Discord.Message){
if (message.author.bot || message.channel.type === ChannelType.DM) return;
if (message.author.bot || message.channel.type === Discord.ChannelType.DM) return;
const msgarr = message.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n]/g, ' ').split(' ');
let automodded: boolean;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
run(client:TClient, msg:Discord.Message){
if (!client.config.botSwitches.logs) return;

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from '../client';
import TClient from '../client.js';
export default {
run(client:TClient, messages:Discord.Collection<string, Discord.Message<boolean>>){
if (!client.config.botSwitches.logs) return;

View File

@ -1,5 +1,5 @@
import Discord, { ActionRowBuilder, ButtonBuilder } from 'discord.js';
import TClient from '../client';
import Discord from 'discord.js';
import TClient from '../client.js';
export default {
async run(client:TClient, oldMsg:Discord.Message, newMsg:Discord.Message){
if (!client.config.botSwitches.logs) return;
@ -8,6 +8,6 @@ export default {
const msgarr = newMsg.content.toLowerCase().replaceAll(/[!@#$%^&*()_+\-=\[\]{};':"\\|,.<>\/?\n]/g, ' ').split(' ');
if (await client.bannedWords._content.findOne({_id:msgarr}) && (!client.isStaff(newMsg.member))) newMsg.delete();
if (newMsg.content === oldMsg.content) return;
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.tag} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : oldMsg.content}\n\`\`\`\nNew content:\n\`\`\`\n${newMsg.content}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new ActionRowBuilder<ButtonBuilder>().addComponents(new ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]});
(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send({embeds: [new client.embed().setColor(client.config.embedColor).setTimestamp().setAuthor({name: `Author: ${oldMsg.author.tag} (${oldMsg.author.id})`, iconURL: `${oldMsg.author.displayAvatarURL()}`}).setTitle('Message edited').setDescription(`<@${oldMsg.author.id}>\nOld content:\n\`\`\`\n${oldMsg.content.length < 1 ? '(Attachment)' : oldMsg.content}\n\`\`\`\nNew content:\n\`\`\`\n${newMsg.content}\`\`\`\nChannel: <#${oldMsg.channelId}>`)], components: [new Discord.ActionRowBuilder<Discord.ButtonBuilder>().addComponents(new Discord.ButtonBuilder().setStyle(5).setURL(`${oldMsg.url}`).setLabel('Jump to message'))]});
}
}

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from './client';
import TClient from './client.js';
const client = new TClient;
client.init();
import fs from 'node:fs';
@ -78,10 +78,11 @@ setInterval(async()=>{
if (results[1].status == 204) embed.setImage('https://http.cat/204');
FScsg.fetchResult = `DagMP CSG failed with ${results[1].status + ' ' + results[1].statusText}`;
embed.addFields({name: 'CSG Status', value: results[1].status + ' ' + results[1].statusText})
} else FScsg.data = client.xjs.xml2js(results[1].data,{compact:true,spaces:2}).careerSavegame as FSCareerSavegame;
} else FScsg.data = (client.xjs.xml2js(results[1].data,{compact:true}) as any).careerSavegame as FSCareerSavegame;
}).catch((error)=>console.log(error))
if (FSdss.fetchResult.length != 0){
error = true;
if (FSdss.data.slots === undefined) return;
console.log(client.logTime(), FSdss.fetchResult);
}
if (FScsg.fetchResult.length != 0){
@ -94,9 +95,9 @@ setInterval(async()=>{
return;
}
const DB = JSON.parse(fs.readFileSync(__dirname + '/database/MPPlayerData.json', {encoding: 'utf8'}));
const DB = JSON.parse(fs.readFileSync('src/database/MPPlayerData.json', {encoding: 'utf8'}));
DB.push(FSdss.data.slots.used)
fs.writeFileSync(__dirname + '/database/MPPlayerData.json', JSON.stringify(DB))
fs.writeFileSync('src/database/MPPlayerData.json', JSON.stringify(DB))
// Number format function
function formatNumber(number: any, digits: any, icon: any){
@ -143,13 +144,13 @@ setInterval(async()=>{
});
const formattedDate = Math.floor((now - lrsStart)/1000/60/60/24);
const dailyMsgs = JSON.parse(fs.readFileSync(__dirname + '/database/dailyMsgs.json', {encoding: 'utf8'}))
const dailyMsgs = JSON.parse(fs.readFileSync('./src/database/dailyMsgs.json', {encoding: 'utf8'}))
if (!dailyMsgs.some((x:Array<number>)=>x[0] === formattedDate)){
let total = (await client.userLevels._content.find({})).reduce((a,b)=>a + b.messages, 0); // sum of all users
const yesterday = dailyMsgs.find((x:Array<number>)=>x[0] === formattedDate - 1);
if (total < yesterday) total = yesterday // messages went down.
dailyMsgs.push([formattedDate, total]);
fs.writeFileSync(__dirname + '/database/dailyMsgs.json', JSON.stringify(dailyMsgs))
fs.writeFileSync('./src/database/dailyMsgs.json', JSON.stringify(dailyMsgs))
console.log(client.logTime(), `Pushed [${formattedDate}, ${total}] to dailyMsgs`);
client.guilds.cache.get(client.config.mainServer.id).commands.fetch().then((commands)=>(client.channels.resolve(client.config.mainServer.channels.logs) as Discord.TextChannel).send(`:pencil: Pushed \`[${formattedDate}, ${total}]\` to </rank leaderboard:${commands.find(x=>x.name == 'rank').id}>`))
}

View File

@ -1,4 +1,4 @@
import TClient from 'src/client';
import TClient from '../client.js';
import mongoose from 'mongoose';
const Schema = mongoose.model('mpserver', new mongoose.Schema({

View File

@ -1,4 +1,4 @@
import TClient from 'src/client';
import TClient from '../client.js';
import mongoose from 'mongoose';
const Schema = mongoose.model('bannedWords', new mongoose.Schema({

View File

@ -1,4 +1,4 @@
import TClient from 'src/client';
import TClient from '../client.js';
import mongoose from 'mongoose';
const Schema = mongoose.model('bonkCount', new mongoose.Schema({

View File

@ -1,8 +1,8 @@
import Discord from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
import mongoose from 'mongoose';
import ms from 'ms';
import {Punishment} from 'src/typings/interfaces';
import {Punishment} from '../typings/interfaces.js';
const Schema = mongoose.model('punishments', new mongoose.Schema({
_id: {type: Number, required: true},

View File

@ -1,4 +1,4 @@
import TClient from 'src/client';
import TClient from '../client.js';
import mongoose from 'mongoose';
const Schema = mongoose.model('suggestion', new mongoose.Schema({

View File

@ -1,5 +1,5 @@
import Discord from 'discord.js';
import TClient from 'src/client';
import TClient from '../client.js';
import mongoose from 'mongoose';
const Schema = mongoose.model('userLevels', new mongoose.Schema({

View File

@ -1,18 +1,20 @@
{
"transpileOnly": true,
"compilerOptions": {
"esModuleInterop": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"target": "ESNext",
"module": "NodeNext",
"baseUrl": "./",
"rootDir": "src/",
"outDir": "dist/",
"moduleResolution": "Node",
"typeRoots": [ "node_modules/@types", "./src/typings" ],
},
"include": [ "node_modules/@types", "src/**/*" ],
"exclude": [ "dist", "node_modules" ],
"transpileOnly": true,
"compilerOptions": {
"skipLibCheck": true,
"esModuleInterop": true,
"resolveJsonModule": true,
"emitDecoratorMetadata": true,
"experimentalDecorators": true,
"allowSyntheticDefaultImports": true,
"target": "ES2022",
"module": "ESNext",
"baseUrl": "./",
"rootDir": "src/",
"outDir": "dist/",
"moduleResolution": "bundler",
"typeRoots": [ "node_modules/@types", "./src/typings" ],
},
"include": [ "node_modules/@types", "src/" ],
"exclude": [ "node_modules", ".git", "src/config.json", "src/DB-Beta.config.json", "src/Toast-Testbot.config.json" ],
}