diff --git a/src/items/index.ts b/src/items/index.ts index 2d9e071..67f8dba 100644 --- a/src/items/index.ts +++ b/src/items/index.ts @@ -1,49 +1,30 @@ -import type { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base"; -import type { specialExecuteArgs, userType } from "lib/commandUtils"; +import { Command, type commandOptions } from "lib/commandUtils"; import type User from "user"; -type itemOptions = { +interface itemOptions extends commandOptions { name: items; - aliases: string[]; prettyName: string; plural: string; description: string; - execution: ( - message: EventSubChannelChatMessageEvent, - sender: User, - args?: specialExecuteArgs, - ) => Promise; - specialaliases?: string[]; price: number; -}; +} -export class Item { +export class Item extends Command { public readonly name: items; public readonly prettyName: string; public readonly plural: string; public readonly description: string; - public readonly aliases: string[]; - public readonly specialaliases: string[]; - public readonly usertype: userType; public readonly price: number; - public readonly execute: ( - message: EventSubChannelChatMessageEvent, - sender: User, - args?: specialExecuteArgs, - ) => Promise; - public readonly disableable: boolean; /** Creates an item object */ constructor(options: itemOptions) { + options.disableable = true; // Items can always be disabled + options.usertype = "chatter"; // Everyone can use items + super(options); this.name = options.name; this.prettyName = options.prettyName; this.plural = options.plural; this.description = options.description; - this.aliases = options.aliases; - this.usertype = "chatter"; // Items are usable by everyone - this.execute = options.execution; - this.disableable = true; - this.specialaliases = options.specialaliases ?? []; this.price = options.price; } } diff --git a/src/lib/commandUtils.ts b/src/lib/commandUtils.ts index da02f2a..ff6fab0 100644 --- a/src/lib/commandUtils.ts +++ b/src/lib/commandUtils.ts @@ -9,7 +9,7 @@ export type specialExecuteArgs = { activation?: string; }; -export type commandOptions = { +export interface commandOptions { name: string; aliases: string[]; usertype: userType; @@ -20,7 +20,7 @@ export type commandOptions = { ) => Promise; disableable?: boolean; specialaliases?: string[]; -}; +} /** The Command class represents a command */ export class Command {