Skip to content
This repository has been archived by the owner on Aug 24, 2022. It is now read-only.

Commit

Permalink
Merge pull request abalabahaha#61 from DonovanDMC/option-types
Browse files Browse the repository at this point in the history
make InteractionDataOptions strictly defined
  • Loading branch information
JustCat80 authored Aug 24, 2021
2 parents 0e68d16 + 01e0256 commit d733b86
Showing 1 changed file with 24 additions and 5 deletions.
29 changes: 24 additions & 5 deletions index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -76,12 +76,31 @@ declare namespace Eris {
type PossiblyUncachedMessage = Message | { channel: TextableChannel | { id: string; guild?: Uncached }; guildID?: string; id: string };

// Interaction
type InteractionDataOptions = {
type InteractionDataOptions = InteractionDataOptionsSubCommand | InteractionDataOptionsSubCommandGroup |InteractionDataOptionsWithValue;
type InteractionDataOptionsWithValue = InteractionDataOptionsString | InteractionDataOptionsInteger | InteractionDataOptionsBoolean | InteractionDataOptionsUser | InteractionDataOptionsChannel | InteractionDataOptionsRole | InteractionDataOptionsMentionable | InteractionDataOptionsNumber;
interface InteractionDataOptionsSubCommand {
name: string;
type: Constants["ApplicationCommandOptionTypes"][keyof Constants["ApplicationCommandOptionTypes"]];
value?: string | number | boolean;
options?: InteractionDataOptions[];
};
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND"];
options: InteractionDataOptions[];
}
interface InteractionDataOptionsSubCommandGroup {
name: string;
type: Constants["ApplicationCommandOptionTypes"]["SUB_COMMAND_GROUP"];
options: InteractionDataOptions[];
}
interface InteractionDataOptionWithValue<T extends (Constants["ApplicationCommandOptionTypes"])[keyof Constants["ApplicationCommandOptionTypes"]], V = unknown> {
name: string;
type: T;
value: V;
}
type InteractionDataOptionsString = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["STRING"], string>;
type InteractionDataOptionsInteger = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["INTEGER"], number>;
type InteractionDataOptionsBoolean = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["BOOLEAN"], boolean>;
type InteractionDataOptionsUser = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["USER"], string>;
type InteractionDataOptionsChannel = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["CHANNEL"], string>;
type InteractionDataOptionsRole = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["ROLE"], string>;
type InteractionDataOptionsMentionable = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["MENTIONABLE"], string>;
type InteractionDataOptionsNumber = InteractionDataOptionWithValue<Constants["ApplicationCommandOptionTypes"]["NUMBER"], number>;

type InteractionOptions = {
type: Constants["InteractionResponseTypes"][keyof Constants["InteractionResponseTypes"]];
Expand Down

0 comments on commit d733b86

Please sign in to comment.