diff --git a/src/events/message.ts b/src/events/message.ts index 769a148..f40a2e5 100644 --- a/src/events/message.ts +++ b/src/events/message.ts @@ -71,6 +71,7 @@ export = { author: message.author, member: message.member, supabase, + guildSettings: server_data[0], config, isDeveloper: config.developers.find(dev => dev.id === message.author.id) } @@ -79,7 +80,7 @@ export = { // ! If Command is NSFW and channel is not marked as such, return if (cmd.nsfw && !ctx.channel.nsfw) return ctx.channel.send( - lingua["en_US"].CHANNEL_NOT_NSFW + lingua[server_data[0].locale].CHANNEL_NOT_NSFW ) if (cmd.AuthorPermissions !== "NONE" && ctx.member?.permissions.has(cmd.AuthorPermissions)) return ctx.channel.send(replace(/PERMISSIONS/gm, cmd.AuthorPermissions.join(", "), lingua["en_US"].INSUFFICIENT_PERMISSIONS)) diff --git a/src/handler/structures/Command.js b/src/handler/structures/Command.js deleted file mode 100755 index 833f780..0000000 --- a/src/handler/structures/Command.js +++ /dev/null @@ -1,14 +0,0 @@ -module.exports = class Command { - constructor(command) { - this.name = command.name || ""; - this.description = command.description || ""; - this.aliases = command.aliases || []; - this.module = command.module || ""; - this.cooldown = command.cooldown || 0; - this.guild = command.guild || false; - this.dev = command.dev || false; - this.nsfw = command.nsfw || false; - this.AuthorPermissions = command.AuthorPermissions || "NONE"; - this.hidden = command.hidden || false; - } -}; diff --git a/src/handler/structures/Command.ts b/src/handler/structures/Command.ts new file mode 100755 index 0000000..dd44bde --- /dev/null +++ b/src/handler/structures/Command.ts @@ -0,0 +1,30 @@ +import { Context, Command as CommandContext } from "../../utils/types"; + +export default class Command { + name: string; + description: string; + aliases: string[]; + module: string; + cooldown: number; + guild: boolean; + dev: boolean; + nsfw: boolean; + AuthorPermissions: string | string[]; + hidden: boolean; + constructor(command: CommandContext) { + this.name = command.name || ""; + this.description = command.description || ""; + this.aliases = command.aliases || []; + this.module = command.module || ""; + this.cooldown = command.cooldown || 0; + this.guild = command.guild || false; + this.dev = command.dev || false; + this.nsfw = command.nsfw || false; + this.AuthorPermissions = command.AuthorPermissions || "NONE"; + this.hidden = command.hidden || false; + } + + async run(ctx: Context) { + ctx.channel.send("This is the deafault Command, overwrite me.") + } +}; diff --git a/src/modules/general/info.ts b/src/modules/general/info.ts index 493b2cc..7a41461 100644 --- a/src/modules/general/info.ts +++ b/src/modules/general/info.ts @@ -1,3 +1,4 @@ +import { Context } from '../../utils/types'; import Command from '../../handler/structures/Command'; export = class Info extends Command { @@ -13,7 +14,7 @@ export = class Info extends Command { }) } - async command(ctx: any) { + async command(ctx: Context) { return console.log("Information Command") } } \ No newline at end of file diff --git a/src/utils/types.ts b/src/utils/types.ts index bbcaffd..587ce77 100644 --- a/src/utils/types.ts +++ b/src/utils/types.ts @@ -1,7 +1,5 @@ -export type CommandContext = { - -} - +import { SupabaseClient } from "@supabase/supabase-js"; +import { Client, Guild, GuildMember, Message, NewsChannel, TextChannel, User } from "discord.js"; export type Server = { readonly id: string @@ -21,4 +19,107 @@ export type Usage = { name: string, type: string amount: number +} + +export type Command = { + name: string; + description: string; + aliases: string[]; + module: string; + cooldown: number; + guild: boolean; + dev: boolean; + nsfw: boolean; + AuthorPermissions: string; + hidden: boolean; +} + +export type Context = { + client: Client; + guild: Guild | null; + message: Message; + channel: TextChannel | NewsChannel; + author: User; + member: GuildMember | null; + supabase: SupabaseClient; + guildSettings: Server; + config: Config; + isDeveloper: string[] +} + +// ! Config Typings + +interface Config { + pkg: Pkg; + variables: Variables; + apis: Apis; + token: string; + supabase: Supabase; + developers: Developer[]; +} + +interface Developer { + id: string; +} + +interface Supabase { + url: string; + key: string; +} + +interface Apis { + sheri: string; + yiffrest: string; +} + +interface Variables { + name: string; + prefix: string[]; +} + +interface Pkg { + name: string; + version: string; + description: string; + main: string; + scripts: Scripts; + repository: Repository; + keywords: any[]; + author: string; + license: string; + bugs: Bugs; + homepage: string; + dependencies: Dependencies; + devDependencies: DevDependencies; +} + +interface DevDependencies { + '@types/node': string; + '@types/ws': string; +} + +interface Dependencies { + '@supabase/supabase-js': string; + '@thaldrin/sourcefinder': string; + chalk: string; + 'discord.js': string; + winston: string; + 'winston-daily-rotate-file': string; + yiff: string; +} + +interface Bugs { + url: string; +} + +interface Repository { + type: string; + url: string; +} + +interface Scripts { + build: string; + start: string; + dev: string; + 'update:subs': string; } \ No newline at end of file