mirror of
https://github.com/thaldrin/thaldrin.git
synced 2024-08-14 23:57:21 +00:00
add types for commands
This commit is contained in:
parent
2e947fbdda
commit
2b0ddfad1f
5 changed files with 139 additions and 20 deletions
|
@ -71,6 +71,7 @@ export = {
|
||||||
author: message.author,
|
author: message.author,
|
||||||
member: message.member,
|
member: message.member,
|
||||||
supabase,
|
supabase,
|
||||||
|
guildSettings: server_data[0],
|
||||||
config,
|
config,
|
||||||
isDeveloper: config.developers.find(dev => dev.id === message.author.id)
|
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 Command is NSFW and channel is not marked as such, return
|
||||||
if (cmd.nsfw && !ctx.channel.nsfw) return ctx.channel.send(
|
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))
|
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))
|
||||||
|
|
|
@ -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;
|
|
||||||
}
|
|
||||||
};
|
|
30
src/handler/structures/Command.ts
Executable file
30
src/handler/structures/Command.ts
Executable file
|
@ -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.")
|
||||||
|
}
|
||||||
|
};
|
|
@ -1,3 +1,4 @@
|
||||||
|
import { Context } from '../../utils/types';
|
||||||
import Command from '../../handler/structures/Command';
|
import Command from '../../handler/structures/Command';
|
||||||
|
|
||||||
export = class Info extends 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")
|
return console.log("Information Command")
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -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 = {
|
export type Server = {
|
||||||
readonly id: string
|
readonly id: string
|
||||||
|
@ -22,3 +20,106 @@ export type Usage = {
|
||||||
type: string
|
type: string
|
||||||
amount: number
|
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;
|
||||||
|
}
|
Loading…
Reference in a new issue