twitch-core
Version:
Twitch bot command client
114 lines (113 loc) • 3.06 kB
TypeScript
import { TwitchChatMessage } from '../messages/TwitchChatMessage';
import { TwitchCommandClient } from '../client/TwitchCommandClient';
interface CommandOptions {
/**
* Command name (default alias)
*/
name: string;
/**
* Userlevel access (everyone, regular, vip, subscriber, moderator, broadcaster)
*/
userlevel: keyof typeof UserLevel;
/**
* Command message text (used on text commands!)
*/
text?: string;
/**
* Command description (required for output to !help <command>)
*/
description?: string;
/**
* Message send type (used on text commands!)
* default: (reply)
*/
messageType?: keyof typeof MessageType;
/**
* Command examples (requited for output to !help <command>)
*/
examples?: string[];
/**
* Command arguments
*/
args?: CommandArgument[];
/**
* More aliases
*/
aliases?: string[];
/**
* The command is available only on the bot channel
* Make sure the client enable `autoJoinBotChannel` parametr
*/
botChannelOnly?: boolean;
/**
* Hide command help output to `!commands`
*/
hideFromHelp?: boolean;
/**
* The command is available only in the private message of the bot
*/
privmsgOnly?: boolean;
}
interface CommandArgument {
/**
* Alias name
*/
name: string;
/**
* Value typesafe
*/
type?: StringConstructor | NumberConstructor | BooleanConstructor;
/**
* Default value
*/
defaultValue?: string | number | boolean;
}
declare enum UserLevel {
vip = "vip",
everyone = "everyone",
regular = "regular",
subscriber = "subscriber",
moderator = "moderator",
broadcaster = "broadcaster"
}
declare enum MessageType {
reply = "reply",
actionReply = "actionReply",
say = "say",
actionSay = "actionSay"
}
declare type CommandProvider = Record<string, CommandOptions>;
declare class TwitchChatCommand {
options: CommandOptions;
client: TwitchCommandClient;
constructor(client: TwitchCommandClient, options: CommandOptions);
/**
* Method called when executeCommand
*
* @param msg
* @param chatter
*/
execute(msg: TwitchChatMessage): Promise<any>;
/**
* Method called when command is executed
* TODO: Fix types
*
* @param msg
* @param parameters
*/
run(msg: TwitchChatMessage, parameters: unknown): Promise<any>;
/**
* Prepare the command to be executed
*
* @param msg
* @param parameters
*/
prepareRun(msg: TwitchChatMessage, parameters: string[]): Promise<any>;
/**
* Pre validation before to known if can execute command
*
* @param msg
*/
preValidate(msg: TwitchChatMessage): string | boolean;
}
export { TwitchChatCommand, CommandOptions, CommandArgument, CommandProvider, UserLevel, MessageType };