-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
72381e7
commit 03954e5
Showing
62 changed files
with
1,056 additions
and
907 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,100 +1,109 @@ | ||
import { ButtonStyle, ComponentType, type APIActionRowComponent, type APIButtonComponent, type APIButtonComponentWithCustomId, type APIButtonComponentWithURL, type APIMessageActionRowComponent, type APIMessageComponent } from "discord.js"; | ||
import { | ||
ButtonStyle, | ||
ComponentType, | ||
type APIActionRowComponent, | ||
type APIButtonComponent, | ||
type APIButtonComponentWithCustomId, | ||
type APIButtonComponentWithURL, | ||
type APIMessageActionRowComponent, | ||
type APIMessageComponent, | ||
} from "discord.js"; | ||
import type { LinkButton, RegularButton } from "../../../Interfaces"; | ||
|
||
export class ButtonBuilder { | ||
private readonly _data: APIButtonComponent[]; | ||
private readonly _data: APIButtonComponent[]; | ||
|
||
/** | ||
* @example | ||
* ```ts | ||
* const Button = new ButtonBuilder(); | ||
* ``` | ||
*/ | ||
constructor() { | ||
this._data = []; | ||
/** | ||
* @example | ||
* ```ts | ||
* const Button = new ButtonBuilder(); | ||
* ``` | ||
*/ | ||
constructor() { | ||
this._data = []; | ||
} | ||
|
||
/** | ||
* Creates a Link Button component | ||
* @param {LinkButton} component_data - The structure of data needed to create the Link Button component | ||
* | ||
* @example | ||
* ```ts | ||
* Button.CreateLinkButton({ | ||
* custom_id: "https://example.com/", | ||
* label: "View Link" | ||
* }); | ||
* ``` | ||
*/ | ||
public CreateLinkButton(component_data: LinkButton): this { | ||
const data: APIButtonComponentWithURL = { | ||
type: ComponentType.Button, | ||
style: ButtonStyle.Link, | ||
url: component_data.custom_id, | ||
disabled: component_data.disabled, | ||
emoji: component_data.emoji, | ||
label: component_data.label, | ||
}; | ||
|
||
/** | ||
* Creates a Link Button component | ||
* @param {LinkButton} component_data - The structure of data needed to create the Link Button component | ||
* | ||
* @example | ||
* ```ts | ||
* Button.CreateLinkButton({ | ||
* custom_id: "https://example.com/", | ||
* label: "View Link" | ||
* }); | ||
* ``` | ||
*/ | ||
public CreateLinkButton(component_data: LinkButton): this { | ||
const data: APIButtonComponentWithURL = { | ||
type: ComponentType.Button, | ||
style: ButtonStyle.Link, | ||
url: component_data.custom_id, | ||
disabled: component_data.disabled, | ||
emoji: component_data.emoji, | ||
label: component_data.label | ||
}; | ||
this._data.push(data); | ||
|
||
this._data.push(data); | ||
return this; | ||
} | ||
|
||
return this; | ||
/** | ||
* Creates a Regular Button component | ||
* @param {RegularButton} component_data - The structure of data needed to create the Regular Button component | ||
* | ||
* @example | ||
* ```ts | ||
* Button.CreateRegularButton({ | ||
* custom_id: "click_me", | ||
* style: ButtonStyle.Primary, | ||
* label: "Click me!" | ||
* }); | ||
* ``` | ||
*/ | ||
public CreateRegularButton(component_data: RegularButton): this { | ||
const data: APIButtonComponentWithCustomId = { | ||
type: ComponentType.Button, | ||
custom_id: component_data.custom_id, | ||
style: component_data.style, | ||
disabled: component_data.disabled, | ||
emoji: component_data.emoji, | ||
label: component_data.label, | ||
}; | ||
|
||
/** | ||
* Creates a Regular Button component | ||
* @param {RegularButton} component_data - The structure of data needed to create the Regular Button component | ||
* | ||
* @example | ||
* ```ts | ||
* Button.CreateRegularButton({ | ||
* custom_id: "click_me", | ||
* style: ButtonStyle.Primary, | ||
* label: "Click me!" | ||
* }); | ||
* ``` | ||
*/ | ||
public CreateRegularButton(component_data: RegularButton): this { | ||
const data: APIButtonComponentWithCustomId = { | ||
type: ComponentType.Button, | ||
custom_id: component_data.custom_id, | ||
style: component_data.style, | ||
disabled: component_data.disabled, | ||
emoji: component_data.emoji, | ||
label: component_data.label | ||
}; | ||
this._data.push(data); | ||
|
||
this._data.push(data); | ||
return this; | ||
} | ||
|
||
return this; | ||
/** | ||
* Builds the action row containing the Link, Premium, and/or Regular Button components | ||
* | ||
* @example | ||
* ```ts | ||
* Button.BuildActionRow(); | ||
* ``` | ||
*/ | ||
public BuildActionRow(): APIActionRowComponent<APIMessageActionRowComponent> { | ||
const data: APIMessageComponent = { | ||
type: ComponentType.ActionRow, | ||
components: this._data, | ||
}; | ||
|
||
/** | ||
* Builds the action row containing the Link, Premium, and/or Regular Button components | ||
* | ||
* @example | ||
* ```ts | ||
* Button.BuildActionRow(); | ||
* ``` | ||
*/ | ||
public BuildActionRow(): APIActionRowComponent<APIMessageActionRowComponent> { | ||
const data: APIMessageComponent = { | ||
type: ComponentType.ActionRow, | ||
components: this._data | ||
}; | ||
|
||
return data; | ||
}; | ||
return data; | ||
} | ||
|
||
/** | ||
* Returns all the Button components | ||
* | ||
* @example | ||
* ```ts | ||
* Button.Components; | ||
* ``` | ||
*/ | ||
public get Components(): APIButtonComponent[] { | ||
return this._data; | ||
}; | ||
}; | ||
/** | ||
* Returns all the Button components | ||
* | ||
* @example | ||
* ```ts | ||
* Button.Components; | ||
* ``` | ||
*/ | ||
public get Components(): APIButtonComponent[] { | ||
return this._data; | ||
} | ||
} |
116 changes: 61 additions & 55 deletions
116
src/Classes/Discord/Builders/ChannelSelectMenuBuilder.ts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,62 +1,68 @@ | ||
import { ComponentType, type APIActionRowComponent, type APIChannelSelectComponent, type APIMessageActionRowComponent, type APIMessageComponent } from "discord.js"; | ||
import { | ||
ComponentType, | ||
type APIActionRowComponent, | ||
type APIChannelSelectComponent, | ||
type APIMessageActionRowComponent, | ||
type APIMessageComponent, | ||
} from "discord.js"; | ||
import type { ChannelSelectMenu } from "../../../Interfaces"; | ||
|
||
export class ChannelSelectMenuBuilder { | ||
private readonly _data: APIChannelSelectComponent[]; | ||
private readonly _data: APIChannelSelectComponent[]; | ||
|
||
/** | ||
* Creates the Channel Select Menu component | ||
* @param {ChannelSelectMenu} data - The structure of data needed to create the Channel Select Menu component | ||
* | ||
* @example | ||
* ```ts | ||
* const SelectMenu = new ChannelSelectMenuBuilder({ | ||
* custom_id: "classrooms", | ||
* placeholder: "Choose a classroom" | ||
* }); | ||
* ``` | ||
*/ | ||
constructor(data: ChannelSelectMenu) { | ||
this._data = [ | ||
{ | ||
type: ComponentType.ChannelSelect, | ||
custom_id: data.custom_id, | ||
channel_types: data.channel_types, | ||
default_values: data.default_values, | ||
disabled: data.disabled, | ||
max_values: data.max_values, | ||
min_values: data.min_values, | ||
placeholder: data.placeholder | ||
} | ||
]; | ||
}; | ||
|
||
/** | ||
* Builds the action row containing the Channel Select Menu component | ||
* | ||
* @example | ||
* ```ts | ||
* SelectMenu.BuildActionRow(); | ||
* ``` | ||
*/ | ||
public BuildActionRow(): APIActionRowComponent<APIMessageActionRowComponent> { | ||
const data: APIMessageComponent = { | ||
type: ComponentType.ActionRow, | ||
components: this._data | ||
}; | ||
/** | ||
* Creates the Channel Select Menu component | ||
* @param {ChannelSelectMenu} data - The structure of data needed to create the Channel Select Menu component | ||
* | ||
* @example | ||
* ```ts | ||
* const SelectMenu = new ChannelSelectMenuBuilder({ | ||
* custom_id: "classrooms", | ||
* placeholder: "Choose a classroom" | ||
* }); | ||
* ``` | ||
*/ | ||
constructor(data: ChannelSelectMenu) { | ||
this._data = [ | ||
{ | ||
type: ComponentType.ChannelSelect, | ||
custom_id: data.custom_id, | ||
channel_types: data.channel_types, | ||
default_values: data.default_values, | ||
disabled: data.disabled, | ||
max_values: data.max_values, | ||
min_values: data.min_values, | ||
placeholder: data.placeholder, | ||
}, | ||
]; | ||
} | ||
|
||
return data; | ||
/** | ||
* Builds the action row containing the Channel Select Menu component | ||
* | ||
* @example | ||
* ```ts | ||
* SelectMenu.BuildActionRow(); | ||
* ``` | ||
*/ | ||
public BuildActionRow(): APIActionRowComponent<APIMessageActionRowComponent> { | ||
const data: APIMessageComponent = { | ||
type: ComponentType.ActionRow, | ||
components: this._data, | ||
}; | ||
|
||
/** | ||
* Returns the Channel Select Menu component | ||
* | ||
* @example | ||
* ```ts | ||
* SelectMenu.Component; | ||
* ``` | ||
*/ | ||
public get Component(): APIChannelSelectComponent[] { | ||
return this._data; | ||
}; | ||
}; | ||
return data; | ||
} | ||
|
||
/** | ||
* Returns the Channel Select Menu component | ||
* | ||
* @example | ||
* ```ts | ||
* SelectMenu.Component; | ||
* ``` | ||
*/ | ||
public get Component(): APIChannelSelectComponent[] { | ||
return this._data; | ||
} | ||
} |
Oops, something went wrong.