2023-12-24 10:21:40 -05:00
|
|
|
interface IRepeatedMessages {
|
|
|
|
[key:string]: {
|
|
|
|
type:string;
|
|
|
|
count:number;
|
|
|
|
firstTime:number;
|
|
|
|
timeout:NodeJS.Timeout;
|
|
|
|
}
|
2023-09-01 00:32:11 -04:00
|
|
|
}
|
2023-08-30 04:34:59 -04:00
|
|
|
import Discord from 'discord.js';
|
2023-10-07 17:01:16 -04:00
|
|
|
import ConfigHelper from './helpers/ConfigHelper.js';
|
|
|
|
import {readdirSync} from 'node:fs';
|
2023-12-24 10:21:40 -05:00
|
|
|
import {Config} from './interfaces';
|
|
|
|
import {
|
|
|
|
DailyMsgsSvc, UserLevelsSvc, BonkCountSvc,
|
|
|
|
MPServerSvc, PunishmentsSvc, ProhibitedWordsSvc,
|
|
|
|
SuggestionsSvc, TagSystemSvc, YouTubeChannelsSvc
|
|
|
|
} from './models/IMPORTS.js';
|
|
|
|
import DatabaseServer from './components/DatabaseServer.js';
|
|
|
|
import CacheServer from './components/CacheServer.js';
|
2023-10-07 17:01:16 -04:00
|
|
|
import fxp from 'fast-xml-parser';
|
|
|
|
import dayjs from 'dayjs';
|
2023-10-04 21:01:36 -04:00
|
|
|
import TSClient from './helpers/TSClient.js';
|
2023-01-06 19:41:20 -05:00
|
|
|
|
2023-08-30 04:34:59 -04:00
|
|
|
export default class TClient extends Discord.Client {
|
2023-12-24 10:21:40 -05:00
|
|
|
public invites: Map<any, any> = new Map();
|
|
|
|
public commands: Discord.Collection<string, any> = new Discord.Collection();
|
|
|
|
public registry: Array<Discord.ApplicationCommandDataResolvable> = [];
|
|
|
|
public config: Config;
|
|
|
|
public embed: typeof Discord.EmbedBuilder = Discord.EmbedBuilder;
|
|
|
|
public collection: typeof Discord.Collection = Discord.Collection;
|
|
|
|
public attachment: typeof Discord.AttachmentBuilder = Discord.AttachmentBuilder;
|
|
|
|
public dayjs: typeof dayjs = dayjs;
|
|
|
|
public fxp: typeof fxp = fxp;
|
|
|
|
public dailyMsgs: DailyMsgsSvc = new DailyMsgsSvc();
|
|
|
|
public userLevels: UserLevelsSvc = new UserLevelsSvc(this);
|
|
|
|
public punishments: PunishmentsSvc = new PunishmentsSvc(this);
|
|
|
|
public bonkCount: BonkCountSvc = new BonkCountSvc();
|
|
|
|
public prohibitedWords: ProhibitedWordsSvc = new ProhibitedWordsSvc();
|
|
|
|
public MPServer: MPServerSvc = new MPServerSvc();
|
|
|
|
public suggestions: SuggestionsSvc = new SuggestionsSvc();
|
|
|
|
public tags: TagSystemSvc = new TagSystemSvc();
|
|
|
|
public ytChannels: YouTubeChannelsSvc = new YouTubeChannelsSvc();
|
|
|
|
public repeatedMessages: IRepeatedMessages = {};
|
|
|
|
public statsGraph: number = -120;
|
2022-11-11 19:58:11 -05:00
|
|
|
|
2023-12-24 10:21:40 -05:00
|
|
|
constructor() {
|
2023-03-05 05:04:10 -05:00
|
|
|
super({
|
|
|
|
intents: [
|
2023-08-30 04:34:59 -04:00
|
|
|
Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMembers,
|
|
|
|
Discord.GatewayIntentBits.GuildModeration, Discord.GatewayIntentBits.GuildInvites,
|
|
|
|
Discord.GatewayIntentBits.GuildMessageReactions, Discord.GatewayIntentBits.GuildPresences,
|
|
|
|
Discord.GatewayIntentBits.MessageContent, Discord.GatewayIntentBits.GuildMessages,
|
2023-10-08 06:10:03 -04:00
|
|
|
Discord.GatewayIntentBits.DirectMessages
|
2023-04-24 07:04:32 -04:00
|
|
|
], partials: [
|
2023-08-30 04:34:59 -04:00
|
|
|
Discord.Partials.Channel, Discord.Partials.Reaction, Discord.Partials.Message
|
2023-12-24 10:21:40 -05:00
|
|
|
], allowedMentions: {users:[], roles:[]}
|
2023-03-05 05:04:10 -05:00
|
|
|
})
|
2023-12-24 10:21:40 -05:00
|
|
|
this.config = ConfigHelper.loadConfig() as Config;
|
|
|
|
this.setMaxListeners(50);
|
2023-03-05 05:04:10 -05:00
|
|
|
}
|
2023-12-24 10:21:40 -05:00
|
|
|
async init() {
|
2023-03-05 05:04:10 -05:00
|
|
|
console.time('Startup');
|
2023-10-06 01:54:27 -04:00
|
|
|
|
2023-12-24 10:21:40 -05:00
|
|
|
const eventFiles = await Promise.all(readdirSync('dist/events').map(file=>import(`./events/${file}`)));
|
2023-10-06 01:54:27 -04:00
|
|
|
eventFiles.forEach((eventFile, index)=>{
|
|
|
|
const eventName = readdirSync('dist/events')[index].replace('.js', '');
|
|
|
|
this.on(eventName, async(...args)=>eventFile.default.run(this, ...args));
|
|
|
|
});
|
|
|
|
|
2023-12-24 10:21:40 -05:00
|
|
|
const commandFiles = await Promise.all(readdirSync('dist/commands').map(file=>import(`./commands/${file}`)));
|
2023-10-06 01:54:27 -04:00
|
|
|
commandFiles.forEach(commandFile=>{
|
|
|
|
const {default: command} = commandFile;
|
|
|
|
this.commands.set(command.data.name, {command, uses: 0});
|
|
|
|
this.registry.push(command.data.toJSON());
|
|
|
|
});
|
|
|
|
|
2023-12-24 10:21:40 -05:00
|
|
|
await Promise.all([
|
|
|
|
CacheServer.init(),
|
|
|
|
DatabaseServer.init(),
|
|
|
|
this.login((await TSClient()).main)
|
|
|
|
]);
|
2023-03-05 05:04:10 -05:00
|
|
|
}
|
2022-11-14 03:45:40 -05:00
|
|
|
}
|