1
0
mirror of https://github.com/toast-ts/Daggerbot-TS.git synced 2024-09-29 12:30:58 -04:00

boredom mopping

This commit is contained in:
AnxietyisReal 2023-02-10 15:01:55 +11:00
parent 5a9c25b498
commit 366e18ac30
4 changed files with 13 additions and 25 deletions

View File

@ -93,6 +93,10 @@ export default class TClient extends Client {
this.commands.set(command.default.data.name, command)
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));
});
}
formatPunishmentType(punishment: Punishment, client: TClient, cancels?: Punishment){
if (punishment.type == 'removeOtherPunishment'){

View File

@ -3,15 +3,9 @@ import TClient from '../client';
export default {
async run(client:TClient, interaction:Discord.ChatInputCommandInteraction){
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
if (interaction.isCommand()){
let Sub:string
try{
Sub = ` ${interaction.options.getSubcommand()}`
}catch(e){
Sub = ''
}
if (interaction.isChatInputCommand()){
const commandFile = client.commands.get(interaction.commandName);
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] ${interaction.user.tag} used /${interaction.commandName}${Sub} in #${interaction.channel.name}`);
console.log(`[${client.moment().format('DD/MM/YY HH:mm:ss')}] ${interaction.user.tag} used /${interaction.commandName} ${interaction.options.getSubcommand(false) ?? ''} in #${interaction.channel.name}`);
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{

View File

@ -30,29 +30,18 @@ client.on('ready', async()=>{
console.log(client.config.botSwitches);
console.log(client.config.whitelistedServers);
(client.channels.resolve(client.config.mainServer.channels.bot_status) as Discord.TextChannel).send(`${client.user.username} is active\n\`\`\`json\n${Object.entries(client.config.botSwitches).map((hi)=>`${hi[0]}: ${hi[1]}`).join('\n')}\`\`\``);
// Event handler
fs.readdirSync('src/events').forEach((file)=>{
const eventFile = require(`./events/${file}`);
client.on(file.replace('.ts', ''), async(...args)=>eventFile.default.run(client,...args));
});
})
// Handle errors
function DZ(error:Error){// Yes, I may have shiternet but I don't need to wake up to like a hundred messages or so.
function DZ(error:Error, location:string){// Yes, I may have shiternet but I don't need to wake up to like a hundred messages or so.
if (['getaddrinfo ENOTFOUND discord.com'].includes(error.message)) return;
console.log(error);
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send({embeds: [new client.embed().setColor('#420420').setTitle('Error caught!').setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]})
(client.channels.resolve(client.config.mainServer.channels.errors) as Discord.TextChannel).send({embeds: [new client.embed().setColor('#420420').setTitle('Error caught!').setFooter({text: location}).setDescription(`**Error:** \`${error.message}\`\n\n**Stack:** \`${`${error.stack}`.slice(0, 2500)}\``)]})
}
process.on('unhandledRejection', async(error: Error)=>{
DZ(error)
});
process.on('uncaughtException', async(error: Error)=>{
DZ(error)
});
process.on('error', async(error: Error)=>{
DZ(error)
});
process.on('unhandledRejection', async(error: Error)=>DZ(error, 'unhandledRejection'));
process.on('uncaughtException', async(error: Error)=>DZ(error, 'uncaughtException'));
process.on('error', async(error: Error)=>DZ(error, 'process-error'));
client.on('error', async(error: Error)=>DZ(error, 'client-error'));
// Daggerwin MP loop
setInterval(async()=>{

View File

@ -124,6 +124,7 @@ export interface Tokens {
token_toast: string
token_tae: string
webhook_url: string
webhook_url_test: string
}
export interface Config {
embedColor: ColorResolvable,