Skip to content

Commit

Permalink
Code cleanup
Browse files Browse the repository at this point in the history
  • Loading branch information
TheDogHusky committed Sep 11, 2024
1 parent 5aebff0 commit 4e58bff
Show file tree
Hide file tree
Showing 20 changed files with 288 additions and 366 deletions.
486 changes: 259 additions & 227 deletions package-lock.json

Large diffs are not rendered by default.

8 changes: 4 additions & 4 deletions package.json
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
"type": "commonjs",
"scripts": {
"start": "npx tsc && cross-env NODE_ENV=production node lib/index.js",
"dev": "cross-env NODE_ENV=development tsx watch src/index"
"dev": "npx tsc && cross-env NODE_ENV=development node lib/index"
},
"repository": {
"type": "git",
Expand All @@ -29,9 +29,9 @@
"@classycrafter/super-logger": "^2.0.0",
"axios": "^1.7.7",
"cross-env": "^7.0.3",
"discord.js": "^14.13.0",
"dotenv": "^16.3.1",
"mongoose": "^7.4.3",
"discord.js": "^14.16.1",
"dotenv": "^16.4.5",
"mongoose": "^8.6.1",
"ms": "^2.1.3",
"nekonya.js": "^1.1.8",
"pterodactyl.js": "^2.1.1",
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/fullrestart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class FullRestartCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
await ctx.reply({
content: client.makeReply('Restarting... See ya!', 'loading'),
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/restart.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class RestartCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
await ctx.reply({
content: client.makeReply('Restarting...', 'loading'),
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/admin/stop.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class StopCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
await ctx.reply({
content: client.makeReply('Stopping... Goodbye!', 'loading'),
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/hug.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class KitsuneCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const user = ctx.options.getUser('user', true);
if (user.id === ctx.user.id) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/kiss.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class KitsuneCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const user = ctx.options.getUser('user', true);
if (user.id === ctx.user.id) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/kitsune.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class KitsuneCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const number = ctx.options.getNumber('number') || 1;
if (number > 3) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/lewd.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class NekoCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const number = ctx.options.getNumber('number') || 1;
if (number > 3) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/neko.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class NekoCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const number = ctx.options.getNumber('number') || 1;
if (number > 3) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/pat.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class KitsuneCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const user = ctx.options.getUser('user', true);
if (user.id === ctx.user.id) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/fun/slap.ts
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ export default class KitsuneCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const user = ctx.options.getUser('user', true);
if (user.id === ctx.user.id) {
await ctx.reply({
Expand Down
2 changes: 1 addition & 1 deletion src/commands/utils/hello.ts
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ export default class HelloCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
await ctx.reply({
content: `Hello, ${ctx.user}!`
});
Expand Down
2 changes: 1 addition & 1 deletion src/commands/utils/help.ts
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ export default class HelpCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const command = ctx.options.getString('command');
if (command) {
const cmd = client.commands.get(command);
Expand Down
8 changes: 4 additions & 4 deletions src/commands/utils/infos.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,10 @@ export default class InfosCommand extends Command {
});
};

public async run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void> {
public async run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void> {
const name = client.user?.tag;
const id = client.user?.id;
const owner = client.config.owners.map((owner) => {
const owners = client.config.owners.map((owner) => {
const user = client.users.cache.get(owner);
return user?.tag || 'An error occurred';
}).join(', ');
Expand Down Expand Up @@ -53,8 +53,8 @@ export default class InfosCommand extends Command {
inline: true
},
{
name: `${client.config.emotes.owner}・Owner`,
value: `> \`${owner}\``,
name: `${client.config.emotes.owner}・Owner(s)`,
value: `> \`${owners}\``,
inline: true
},
{
Expand Down
7 changes: 4 additions & 3 deletions src/events/interactionCreate.ts
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import Event from '../struct/event';
import Client from '../struct/client';
import { ChatInputCommandInteraction, ChannelType } from 'discord.js';
import { ChatInputCommandInteraction } from 'discord.js';

export default class InteractionCreateEvent extends Event {
public constructor(client: Client) {
Expand All @@ -12,11 +12,12 @@ export default class InteractionCreateEvent extends Event {

public async run(client: Client, ctx: ChatInputCommandInteraction): Promise<void> {
if (!ctx.isCommand()) return;
if (!ctx.guild) return;
if (!ctx.inGuild() || !ctx.guild) return;
if (!ctx.inCachedGuild()) return;
if (!client.isReady()) return;
if (!ctx.channel) return;
if (!ctx.channel.isTextBased()) return;
if (ctx.channel.type === ChannelType.DM) return;
if (ctx.channel.isDMBased()) return;

const data = await client.database.getGuild(ctx.guild.id);
const command = client.commands.get(ctx.commandName);
Expand Down
2 changes: 1 addition & 1 deletion src/struct/client.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@ import Database from './database';
import { Logger } from '@classycrafter/super-logger';
import * as conf from '../config';
import Ptero from './ptero';
import {getAPIStatus, wait} from './functions';
import { getAPIStatus, wait } from './functions';

config();

Expand Down
6 changes: 3 additions & 3 deletions src/struct/command.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { Client, ApplicationCommandType, ChatInputCommandInteraction, APIApplicationCommandOption } from 'discord.js';
import { Client, ApplicationCommandType, ChatInputCommandInteraction } from 'discord.js';
import { IInfos, IGuild, CommandOptions } from './typings';

export default abstract class Command {
Expand All @@ -24,7 +24,7 @@ export default abstract class Command {
this.defer = options.defer;
};

public abstract run(client: Client, ctx: ChatInputCommandInteraction, data: IGuild): Promise<void>;
public abstract run(client: Client, ctx: ChatInputCommandInteraction<"cached">, data: IGuild): Promise<void>;

public getPostableData(): any {
return {
Expand All @@ -35,7 +35,7 @@ export default abstract class Command {
};
};

public async onError(ctx: ChatInputCommandInteraction, error: Error): Promise<void> {
public async onError(ctx: ChatInputCommandInteraction<"cached">, error: Error): Promise<void> {
if (ctx.deferred || ctx.replied) {
await ctx.editReply({
content: `An error occured while executing this command: \`${error.message}\``
Expand Down
111 changes: 0 additions & 111 deletions src/struct/timings.ts

This file was deleted.

2 changes: 1 addition & 1 deletion src/struct/typings.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import {APIApplicationCommandOption, ColorResolvable} from 'discord.js';
import { APIApplicationCommandOption, ColorResolvable } from 'discord.js';
import { Document } from 'mongoose';
import Guild from '../models/guild';

Expand Down

0 comments on commit 4e58bff

Please sign in to comment.