mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
item class now extends command class, previously was implicit, now explicit
This commit is contained in:
@@ -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<void>;
|
||||
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<void>;
|
||||
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;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -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<void>;
|
||||
disableable?: boolean;
|
||||
specialaliases?: string[];
|
||||
};
|
||||
}
|
||||
|
||||
/** The Command class represents a command */
|
||||
export class Command {
|
||||
|
||||
Reference in New Issue
Block a user