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 { 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;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -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 {
|
||||||
|
|||||||
Reference in New Issue
Block a user