import { ChatInputCommandInteraction, GuildChannel, GuildMember, Message, Role, User } from "discord.js";
import { PrismaClient } from "@prisma/client";
import { BaseEntry, BaseGuildCache, CommandPayload, iSlashData, ResponseBuilder } from "../";
export declare enum CommandType {
Slash = "slash",
Message = "message"
}
export default abstract class BaseCommand
> {
/**
* If the slash command should be deferred
*
* @example true
*/
abstract defer: boolean;
/**
* If the slash command should be ephemeral
*
* @example true
*/
abstract ephemeral: boolean;
/**
* Metadata about the command that will be showed in the help command and the slash command description
*
* @example
* {
* "description": "Plays a song",
* "options": [
* {
* name: "query",
* description: "The link of the song to play",
* type: "string" as const,
* requirements: "Text or URL",
* required: true
* }
* ]
* }
*/
abstract data: iSlashData;
/**
* Enter this field if you want this command to only with either Message or Slash commands
* If not set, this command will work for both.
*
* @example
* CommandType.Slash
*/
only: CommandType | null;
/**
* Middleware to run before the {@link execute} method is called
*/
abstract middleware: CommandMiddleware
[];
/**
* The condition under which a message send will trigger this command.
*
* This can be left empty is {@link only} is set to {@link CommandType.Slash}
*
* @example helper.isMessageCommand(true)
*
* @param helper The CommandHelper containing information about the message or slash interaction
*/
abstract condition(helper: CommandHelper
): boolean | void;
/**
* The function that turns a string into a json object with all the command arguments.
*
* This can be left empty is {@link only} is set to {@link CommandType.Slash}
*
* @param helper The CommandHelper containing information about the message or slash interaction
*/
abstract converter(helper: CommandHelper
): any;
/**
* The method that is called when a message or slash command is triggered
*
* @param helper The CommandHelper containing information about the message or slash interaction
*/
abstract execute(helper: CommandHelper
): Promise;
}
export declare abstract class CommandMiddleware> {
/**
* The function that should handle the message or slash interaction
*
* @param helper The CommandHelper containing information about the message or slash interaction
* @returns If the next middleware / execute method should be called
*/
abstract handler(helper: CommandHelper
): boolean | Promise;
}
export declare class CommandHelper> {
private readonly name;
/**
* The type of command that is being handled
*
* Either {@link CommandType.Slash} or {@link CommandType.Message}
*/
readonly type: CommandType;
readonly cache: GC;
readonly interaction?: ChatInputCommandInteraction | undefined;
readonly message?: Message | undefined;
private responded;
private response;
private timeout;
params: Record;
constructor(name: string,
/**
* The type of command that is being handled
*
* Either {@link CommandType.Slash} or {@link CommandType.Message}
*/
type: CommandType, cache: GC, interaction?: ChatInputCommandInteraction | undefined, message?: Message | undefined);
/**
* The GuildMember that send the message or triggered the slash command
*/
get member(): GuildMember;
/**
* Tests the message against the given regex pattern
*
* @param regexp The regexp to match against the message
* @throws Error if the command is a slash command
* @returns The groups that the regex match returned
*/
match(regexp: string): string[] | null;
/**
* A convenience method to test if a message content matches a specific regex pattern of a command.
*
* If the command is **play**, the prefix is **!** and `isMessageCommand(true)` is passed,
* **!play hello** will trigger this command while **!play** with or without trailing spaces will not.
*
* If the command is **loop**, the prefix is **!** and `isMessageCommand(false)` is passed,
* **!loop** with or without trailing spaces will trigger this command while **!loop again** will not.
*
* If the command is **repeat**, the prefix is **!** and `isMessageCommand(null)` is passed,
* **!repeat 5** and **!repeat** with or without trailing spaces will trigger this command.
*
* @param hasArgs If the command is expecting arguments
* @throws Error if the command is a slash command
* @returns If the message content matches the command
*/
isMessageCommand(hasArgs: boolean | null): boolean;
/**
* Gets the arguments passed in the message command
*
* @throws Error if the command is a slash command
* @returns The arguments passed in the message
*/
args(): string[];
/**
* Respond to the message or slash command with a message
* If this method is called more than once, the previous message will be edited
*
* @param options The data to send back to the user
* @param ms The message delete timer, defaults to 5 seconds
*/
respond(options: ResponseBuilder | CommandPayload, ms?: number | null): void;
/**
* Gets a mentionable from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns Mentionable
*/
mentionable(name: string): GuildMember | User | Role | null;
/**
* Gets a mentionable from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns Channel
*/
channel(name: string): GuildChannel | null;
/**
* Gets a role from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns Role
*/
role(name: string): Role | null;
/**
* Gets a user from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns User
*/
user(name: string): User | null;
/**
* Gets a string from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns String
*/
string(name: string): string | null;
/**
* Gets a integer from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns Integer
*/
integer(name: string): number | null;
/**
* Gets a boolean from the slash command options or converted json object of the data
*
* @param name Key in the slash command options or converted json object of the data
* @returns Boolean
*/
boolean(name: string): boolean | null;
}