Skip to content

Commit

Permalink
Remove unnecessary builder imports from message component classes
Browse files Browse the repository at this point in the history
  • Loading branch information
Arcoz0308 committed Jun 16, 2024
1 parent 13fa7f4 commit c81c1e4
Show file tree
Hide file tree
Showing 6 changed files with 4 additions and 35 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { InteractionBase } from "#/base/interaction/interaction.class";
import type { ComponentBuilderField, ComponentType } from "#/base/message_component/base/base_component.type";
import type { ComponentType } from "#/base/message_component/base/base_component.type";

export abstract class BaseComponent extends InteractionBase {

Expand All @@ -9,9 +9,4 @@ export abstract class BaseComponent extends InteractionBase {

abstract type: ComponentType;

/*
Only here for type check, make builder accessible without the class
*/
abstract builder: ComponentBuilderField;

}
Original file line number Diff line number Diff line change
@@ -1,12 +1,7 @@
import type { componentTypes } from "#/base/message_component/base/base_component.enum";
import type { Button } from "#/base/message_component/button/button.class";
import type { ModalSubmitComponent } from "#/base/message_component/modal_submit/modal_submit.class";
import type { MessageActionRowComponentBuilder, ModalBuilder } from "@discordjs/builders";
import type { SelectMenu } from "#/base/message_component/select_menu/select_menu.class";

export type ComponentType = keyof typeof componentTypes;
export type Component = Button|ModalSubmitComponent|SelectMenu;

type ComponentBuilder = MessageActionRowComponentBuilder|ModalBuilder;

export type ComponentBuilderField<T extends ComponentBuilder = ComponentBuilder> = T | ((...args: unknown[]) => T);
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BaseComponent } from "#/base/message_component/base/base_component.class";
import type { ComponentBuilderField, ComponentType } from "#/base/message_component/base/base_component.type";
import type { ButtonBuilder } from "@discordjs/builders";
import type { ComponentType } from "#/base/message_component/base/base_component.type";
import type { ButtonRunContext, ButtonRunResult } from "#/base/message_component/button/button.type";
import type { InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from "discord.js";
import { anyToError, ButtonError, error, ok } from "#/utils";
Expand All @@ -9,8 +8,6 @@ export abstract class Button extends BaseComponent {

type: ComponentType = "button";

abstract builder: ComponentBuilderField<ButtonBuilder>;

authorOnly = false;

abstract run(ctx: ButtonRunContext): Promise<ButtonRunResult>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
import { BaseComponent } from "#/base/message_component/base/base_component.class";
import type { ComponentBuilderField, ComponentType } from "#/base/message_component/base/base_component.type";
import type { ModalBuilder } from "@discordjs/builders";
import type { ComponentType } from "#/base/message_component/base/base_component.type";
import type {
ModalSubmitRunContext,
ModalSubmitRunResult
Expand All @@ -12,8 +11,6 @@ export abstract class ModalSubmitComponent extends BaseComponent {

type: ComponentType = "modalSubmit";

abstract builder: ComponentBuilderField<ModalBuilder>

abstract run(ctx: ModalSubmitRunContext): Promise<ModalSubmitRunResult>;


Expand Down
Original file line number Diff line number Diff line change
@@ -1,19 +1,13 @@
import { BaseComponent } from "#/base/message_component/base/base_component.class";
import type { ComponentType } from "#/base/message_component/base/base_component.type";
import type {
AnySelectMenuBuilder,
SelectMenuRunContext,
SelectMenuRunResult
} from "#/base/message_component/select_menu/select_menu.type";
import type { SelectMenuRunContext, SelectMenuRunResult } from "#/base/message_component/select_menu/select_menu.type";
import type { InteractionEditReplyOptions, InteractionReplyOptions, MessagePayload } from "discord.js";
import { anyToError, error, ok, SelectMenuError } from "#/utils";

export abstract class SelectMenu extends BaseComponent {

type: ComponentType = "selectMenu";

abstract builder: AnySelectMenuBuilder;

authorOnly: boolean = false;

abstract run(ctx: SelectMenuRunContext): Promise<SelectMenuRunResult>
Expand Down
Original file line number Diff line number Diff line change
@@ -1,16 +1,7 @@
import type { Result } from "#/utils/error/error.type";
import type {
ChannelSelectMenuBuilder,
MentionableSelectMenuBuilder,
RoleSelectMenuBuilder,
StringSelectMenuBuilder,
UserSelectMenuBuilder
} from "@discordjs/builders";
import type { SelectMenuError } from "#/utils/error/class/select_menu_error";
import type { AnySelectMenuInteraction } from "discord.js";

export type AnySelectMenuBuilder = ChannelSelectMenuBuilder|MentionableSelectMenuBuilder|RoleSelectMenuBuilder|
StringSelectMenuBuilder|UserSelectMenuBuilder;

export type SelectMenuRunResult = Result<string|true, SelectMenuError>

Expand Down

0 comments on commit c81c1e4

Please sign in to comment.