Skip to content

Commit

Permalink
✨ Add custom StringSelectMenuBuilder
Browse files Browse the repository at this point in the history
  • Loading branch information
Ashu11-A committed May 25, 2024
1 parent 82301f5 commit 9b94340
Show file tree
Hide file tree
Showing 3 changed files with 66 additions and 3 deletions.
23 changes: 22 additions & 1 deletion plugins/plugin_base/src/discord/base/CustomIntetaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionRowBuilder, APIActionRowComponent, APIModalActionRowComponent, ButtonBuilder as Button, ButtonStyle, ComponentEmojiResolvable, ModalBuilder as Modal, ModalComponentData, TextInputBuilder } from "discord.js";
import { ActionRowBuilder, BaseSelectMenuComponentData, ButtonBuilder as Button, ButtonStyle, ComponentEmojiResolvable, ComponentType, ModalBuilder as Modal, SelectMenuComponentOptionData, StringSelectMenuBuilder as StringSelect, TextInputBuilder } from "discord.js";
import { name } from '../../../package.json';

export interface BaseButtonComponentData {
Expand Down Expand Up @@ -44,4 +44,25 @@ export class ModalBuilder extends Modal {
if (components) this.setComponents(components)
this.setCustomId(`${name}_${customId}`)
}
}

interface StringSelectMenuComponentData {
customId: string;
options: SelectMenuComponentOptionData[];
disabled?: boolean;
maxValues?: number;
minValues?: number;
placeholder?: string;
}

export class StringSelectMenuBuilder extends StringSelect {
constructor({ customId, options, disabled, maxValues, minValues, placeholder }: StringSelectMenuComponentData) {
super()
this.setOptions(options)
this.setCustomId(`${name}_${customId}`)
if (disabled) this.setDisabled(disabled)
if (maxValues) this.setMaxValues(maxValues)
if (minValues) this.setMinValues(minValues)
if (placeholder) this.setPlaceholder(placeholder)
}
}
23 changes: 22 additions & 1 deletion plugins/tickets/src/discord/base/CustomIntetaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionRowBuilder, APIActionRowComponent, APIModalActionRowComponent, ButtonBuilder as Button, ButtonStyle, ComponentEmojiResolvable, ModalBuilder as Modal, ModalComponentData, TextInputBuilder } from "discord.js";
import { ActionRowBuilder, BaseSelectMenuComponentData, ButtonBuilder as Button, ButtonStyle, ComponentEmojiResolvable, ComponentType, ModalBuilder as Modal, SelectMenuComponentOptionData, StringSelectMenuBuilder as StringSelect, TextInputBuilder } from "discord.js";
import { name } from '../../../package.json';

export interface BaseButtonComponentData {
Expand Down Expand Up @@ -44,4 +44,25 @@ export class ModalBuilder extends Modal {
if (components) this.setComponents(components)
this.setCustomId(`${name}_${customId}`)
}
}

interface StringSelectMenuComponentData {
customId: string;
options: SelectMenuComponentOptionData[];
disabled?: boolean;
maxValues?: number;
minValues?: number;
placeholder?: string;
}

export class StringSelectMenuBuilder extends StringSelect {
constructor({ customId, options, disabled, maxValues, minValues, placeholder }: StringSelectMenuComponentData) {
super()
this.setOptions(options)
this.setCustomId(`${name}_${customId}`)
if (disabled) this.setDisabled(disabled)
if (maxValues) this.setMaxValues(maxValues)
if (minValues) this.setMinValues(minValues)
if (placeholder) this.setPlaceholder(placeholder)
}
}
23 changes: 22 additions & 1 deletion plugins/utils/src/discord/base/CustomIntetaction.ts
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
import { ActionRowBuilder, APIActionRowComponent, APIModalActionRowComponent, ButtonBuilder as Button, ButtonStyle, ComponentEmojiResolvable, ModalBuilder as Modal, ModalComponentData, TextInputBuilder } from "discord.js";
import { ActionRowBuilder, BaseSelectMenuComponentData, ButtonBuilder as Button, ButtonStyle, ComponentEmojiResolvable, ComponentType, ModalBuilder as Modal, SelectMenuComponentOptionData, StringSelectMenuBuilder as StringSelect, TextInputBuilder } from "discord.js";
import { name } from '../../../package.json';

export interface BaseButtonComponentData {
Expand Down Expand Up @@ -44,4 +44,25 @@ export class ModalBuilder extends Modal {
if (components) this.setComponents(components)
this.setCustomId(`${name}_${customId}`)
}
}

interface StringSelectMenuComponentData {
customId: string;
options: SelectMenuComponentOptionData[];
disabled?: boolean;
maxValues?: number;
minValues?: number;
placeholder?: string;
}

export class StringSelectMenuBuilder extends StringSelect {
constructor({ customId, options, disabled, maxValues, minValues, placeholder }: StringSelectMenuComponentData) {
super()
this.setOptions(options)
this.setCustomId(`${name}_${customId}`)
if (disabled) this.setDisabled(disabled)
if (maxValues) this.setMaxValues(maxValues)
if (minValues) this.setMinValues(minValues)
if (placeholder) this.setPlaceholder(placeholder)
}
}

0 comments on commit 9b94340

Please sign in to comment.