mirror of
https://github.com/toast-ts/Daggerbot-TS.git
synced 2024-12-28 08:55:38 -05:00
boredom mopping
This commit is contained in:
parent
c6046f4660
commit
135448939a
@ -93,6 +93,10 @@ export default class TClient extends Client {
|
|||||||
this.commands.set(command.default.data.name, command)
|
this.commands.set(command.default.data.name, command)
|
||||||
this.registry.push(command.default.data.toJSON())
|
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){
|
formatPunishmentType(punishment: Punishment, client: TClient, cancels?: Punishment){
|
||||||
if (punishment.type == 'removeOtherPunishment'){
|
if (punishment.type == 'removeOtherPunishment'){
|
||||||
|
@ -3,15 +3,9 @@ import TClient from '../client';
|
|||||||
export default {
|
export default {
|
||||||
async run(client:TClient, interaction:Discord.ChatInputCommandInteraction){
|
async run(client:TClient, interaction:Discord.ChatInputCommandInteraction){
|
||||||
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
|
if (!interaction.inGuild() || !interaction.inCachedGuild() || !interaction.command) return;
|
||||||
if (interaction.isCommand()){
|
if (interaction.isChatInputCommand()){
|
||||||
let Sub:string
|
|
||||||
try{
|
|
||||||
Sub = ` ${interaction.options.getSubcommand()}`
|
|
||||||
}catch(e){
|
|
||||||
Sub = ''
|
|
||||||
}
|
|
||||||
const commandFile = client.commands.get(interaction.commandName);
|
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 (!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){
|
if (commandFile){
|
||||||
try{
|
try{
|
||||||
|
23
src/index.ts
23
src/index.ts
@ -30,29 +30,18 @@ client.on('ready', async()=>{
|
|||||||
console.log(client.config.botSwitches);
|
console.log(client.config.botSwitches);
|
||||||
console.log(client.config.whitelistedServers);
|
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')}\`\`\``);
|
(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
|
// 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;
|
if (['getaddrinfo ENOTFOUND discord.com'].includes(error.message)) return;
|
||||||
console.log(error);
|
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)=>{
|
process.on('unhandledRejection', async(error: Error)=>DZ(error, 'unhandledRejection'));
|
||||||
DZ(error)
|
process.on('uncaughtException', async(error: Error)=>DZ(error, 'uncaughtException'));
|
||||||
});
|
process.on('error', async(error: Error)=>DZ(error, 'process-error'));
|
||||||
process.on('uncaughtException', async(error: Error)=>{
|
client.on('error', async(error: Error)=>DZ(error, 'client-error'));
|
||||||
DZ(error)
|
|
||||||
});
|
|
||||||
process.on('error', async(error: Error)=>{
|
|
||||||
DZ(error)
|
|
||||||
});
|
|
||||||
|
|
||||||
// Daggerwin MP loop
|
// Daggerwin MP loop
|
||||||
setInterval(async()=>{
|
setInterval(async()=>{
|
||||||
|
1
src/typings/interfaces.d.ts
vendored
1
src/typings/interfaces.d.ts
vendored
@ -124,6 +124,7 @@ export interface Tokens {
|
|||||||
token_toast: string
|
token_toast: string
|
||||||
token_tae: string
|
token_tae: string
|
||||||
webhook_url: string
|
webhook_url: string
|
||||||
|
webhook_url_test: string
|
||||||
}
|
}
|
||||||
export interface Config {
|
export interface Config {
|
||||||
embedColor: ColorResolvable,
|
embedColor: ColorResolvable,
|
||||||
|
Loading…
Reference in New Issue
Block a user