item class now extends command class, previously was implicit, now explicit

This commit is contained in:
2025-12-03 02:20:01 +01:00
parent 5ddbad1212
commit 87a99331a8
2 changed files with 9 additions and 28 deletions

View File

@@ -1,49 +1,30 @@
import type { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base"; import { Command, type commandOptions } from "lib/commandUtils";
import type { specialExecuteArgs, userType } from "lib/commandUtils";
import type User from "user"; import type User from "user";
type itemOptions = { interface itemOptions extends commandOptions {
name: items; name: items;
aliases: string[];
prettyName: string; prettyName: string;
plural: string; plural: string;
description: string; description: string;
execution: (
message: EventSubChannelChatMessageEvent,
sender: User,
args?: specialExecuteArgs,
) => Promise<void>;
specialaliases?: string[];
price: number; price: number;
}; }
export class Item { export class Item extends Command {
public readonly name: items; public readonly name: items;
public readonly prettyName: string; public readonly prettyName: string;
public readonly plural: string; public readonly plural: string;
public readonly description: string; public readonly description: string;
public readonly aliases: string[];
public readonly specialaliases: string[];
public readonly usertype: userType;
public readonly price: number; public readonly price: number;
public readonly execute: (
message: EventSubChannelChatMessageEvent,
sender: User,
args?: specialExecuteArgs,
) => Promise<void>;
public readonly disableable: boolean;
/** Creates an item object */ /** Creates an item object */
constructor(options: itemOptions) { 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.name = options.name;
this.prettyName = options.prettyName; this.prettyName = options.prettyName;
this.plural = options.plural; this.plural = options.plural;
this.description = options.description; 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; this.price = options.price;
} }
} }

View File

@@ -9,7 +9,7 @@ export type specialExecuteArgs = {
activation?: string; activation?: string;
}; };
export type commandOptions = { export interface commandOptions {
name: string; name: string;
aliases: string[]; aliases: string[];
usertype: userType; usertype: userType;
@@ -20,7 +20,7 @@ export type commandOptions = {
) => Promise<void>; ) => Promise<void>;
disableable?: boolean; disableable?: boolean;
specialaliases?: string[]; specialaliases?: string[];
}; }
/** The Command class represents a command */ /** The Command class represents a command */
export class Command { export class Command {