Skip to content

Commit

Permalink
Simplify and clean up some builder type unions
Browse files Browse the repository at this point in the history
  • Loading branch information
Mimickal committed Sep 2, 2023
1 parent 368f986 commit 5159bd6
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 22 deletions.
15 changes: 0 additions & 15 deletions src/builders.ts
Original file line number Diff line number Diff line change
Expand Up @@ -98,21 +98,6 @@ class CommandHandlerMixin<T extends Discord.CommandInteraction> {
}
}

/**
* Discord.js builders are not designed to be grouped together in a collection.
* This union represents any possible end value for an individual command's
* builder.
*/
export type SlashCommandBuilderReturn =
| SlashCommandBuilder
| Omit<SlashCommandBuilder, 'addSubcommand' | 'addSubcommandGroup'>
| SlashCommandSubcommandsOnlyBuilder;

type SlashCommandSubcommandsOnlyBuilder = Omit<SlashCommandBuilder,
| Exclude<keyof Discord.SharedSlashCommandOptions, 'options'>
| keyof MoreOptionsMixin
>;

// NOTE: it's important that Discord's built-ins are the last Mixin in the list!
// Otherwise, we run the risk of stepping on field initialization.

Expand Down
12 changes: 5 additions & 7 deletions src/registry.ts
Original file line number Diff line number Diff line change
Expand Up @@ -11,15 +11,15 @@ import {
BaseInteraction,
ChatInputCommandInteraction,
CommandInteraction,
ContextMenuCommandBuilder as DiscordContextMenuCommandBuilder,
ContextMenuCommandInteraction,
DiscordAPIError,
ContextMenuCommandBuilder as DiscordContextMenuCommandBuilder,
SlashCommandBuilder as DiscordSlashCommandBuilder,
REST,
RESTPostAPIChatInputApplicationCommandsJSONBody,
RESTPostAPIContextMenuApplicationCommandsJSONBody,
Routes,
SlashCommandBuilder as DiscordSlashCommandBuilder,
Snowflake,
RESTPostAPIContextMenuApplicationCommandsJSONBody,
RESTPostAPIChatInputApplicationCommandsJSONBody,
} from 'discord.js';

import {
Expand All @@ -29,14 +29,12 @@ import {
Handler,
resolveBuilder,
SlashCommandBuilder,
SlashCommandBuilderReturn,
SlashCommandSubcommandBuilder,
SlashCommandSubcommandGroupBuilder,
} from './builders';
import { API_VERSION } from './constants';

/** A top-level command builder. */
type TopLevelBuilder = SlashCommandBuilderReturn | ContextMenuCommandBuilder;
type TopLevelBuilder = ContextMenuCommandBuilder | SlashCommandBuilder

/** Optional parameters for registering commands. */
interface RegisterOpts {
Expand Down

0 comments on commit 5159bd6

Please sign in to comment.