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
|
|
|
}
|
2024-01-19 07:26:39 -05:00
|
|
|
interface ICrosspostSpam {
|
|
|
|
[key:string]: {
|
|
|
|
message:string;
|
|
|
|
channelId:string[];
|
|
|
|
}
|
|
|
|
}
|
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 22:02:59 -05:00
|
|
|
import {Config} from 'src/interfaces';
|
2023-12-24 10:21:40 -05:00
|
|
|
import {
|
2024-01-14 03:06:27 -05:00
|
|
|
DailyMsgsSvc, UserLevelsSvc,
|
2023-12-24 10:21:40 -05:00
|
|
|
MPServerSvc, PunishmentsSvc, ProhibitedWordsSvc,
|
|
|
|
SuggestionsSvc, TagSystemSvc, YouTubeChannelsSvc
|
|
|
|
} from './models/IMPORTS.js';
|
|
|
|
import DatabaseServer from './components/DatabaseServer.js';
|
|
|
|
import CacheServer from './components/CacheServer.js';
|
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();
|
2023-12-24 22:02:59 -05:00
|
|
|
public registry: Discord.ApplicationCommandDataResolvable[] = [];
|
2023-12-24 10:21:40 -05:00
|
|
|
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 dailyMsgs: DailyMsgsSvc = new DailyMsgsSvc();
|
|
|
|
public userLevels: UserLevelsSvc = new UserLevelsSvc(this);
|
|
|
|
public punishments: PunishmentsSvc = new PunishmentsSvc(this);
|
|
|
|
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 = {};
|
2024-01-19 07:26:39 -05:00
|
|
|
public crosspostSpam: ICrosspostSpam = {};
|
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,
|
2023-12-26 17:49:07 -05:00
|
|
|
Discord.GatewayIntentBits.GuildPresences, Discord.GatewayIntentBits.MessageContent,
|
|
|
|
Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.DirectMessages
|
2023-04-24 07:04:32 -04:00
|
|
|
], partials: [
|
2023-12-26 17:49:07 -05:00
|
|
|
Discord.Partials.Channel, 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
|
|
|
}
|