Skip to content

Commit

Permalink
chore: Prettier fix
Browse files Browse the repository at this point in the history
  • Loading branch information
DarkSpencer committed Jul 17, 2024
1 parent 72381e7 commit 03954e5
Show file tree
Hide file tree
Showing 62 changed files with 1,056 additions and 907 deletions.
179 changes: 94 additions & 85 deletions src/Classes/Discord/Builders/ButtonBuilder.ts
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 src/Classes/Discord/Builders/ChannelSelectMenuBuilder.ts
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;
}
}
Loading

0 comments on commit 03954e5

Please sign in to comment.