ci: api-extractor support for docs

This commit is contained in:
iCrawl
2022-06-30 15:46:14 +02:00
parent 525bf031a5
commit b2776c22d4
54 changed files with 2608 additions and 343 deletions

View File

@@ -36,8 +36,8 @@ export class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBu
/**
* Adds components to this action row.
* @param components The components to add to this action row.
* @returns
*
* @param components - The components to add to this action row.
*/
public addComponents(...components: RestOrArray<T>) {
this.components.push(...normalizeArray(components));
@@ -46,7 +46,8 @@ export class ActionRowBuilder<T extends AnyComponentBuilder> extends ComponentBu
/**
* Sets the components in this action row
* @param components The components to set this row to
*
* @param components - The components to set this row to
*/
public setComponents(...components: RestOrArray<T>) {
this.components.splice(0, this.components.length, ...normalizeArray(components));

View File

@@ -11,7 +11,8 @@ export interface MappedComponentTypes {
/**
* Factory for creating components from API data
* @param data The api data to transform to a component class
*
* @param data - The api data to transform to a component class
*/
export function createComponentBuilder<T extends keyof MappedComponentTypes>(
data: (APIMessageComponent | APIModalComponent) & { type: T },

View File

@@ -18,7 +18,8 @@ export class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
/**
* Sets the style of this button
* @param style The style of the button
*
* @param style - The style of the button
*/
public setStyle(style: ButtonStyle) {
this.data.style = style;
@@ -27,7 +28,8 @@ export class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
/**
* Sets the URL for this button
* @param url The URL to open when this button is clicked
*
* @param url - The URL to open when this button is clicked
*/
public setURL(url: string) {
(this.data as APIButtonComponentWithURL).url = url;
@@ -36,7 +38,8 @@ export class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
/**
* Sets the custom Id for this button
* @param customId The custom id to use for this button
*
* @param customId - The custom id to use for this button
*/
public setCustomId(customId: string) {
(this.data as APIButtonComponentWithCustomId).custom_id = customId;
@@ -45,7 +48,8 @@ export class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
/**
* Sets the emoji to display on this button
* @param emoji The emoji to display on this button
*
* @param emoji - The emoji to display on this button
*/
public setEmoji(emoji: APIMessageComponentEmoji) {
this.data.emoji = emoji;
@@ -54,7 +58,8 @@ export class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
/**
* Sets whether this button is disable or not
* @param disabled Whether or not to disable this button or not
*
* @param disabled - Whether or not to disable this button or not
*/
public setDisabled(disabled = true) {
this.data.disabled = disabled;
@@ -63,7 +68,8 @@ export class UnsafeButtonBuilder extends ComponentBuilder<APIButtonComponent> {
/**
* Sets the label for this button
* @param label The label to display on this button
*
* @param label - The label to display on this button
*/
public setLabel(label: string) {
this.data.label = label;

View File

@@ -20,7 +20,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Sets the placeholder for this select menu
* @param placeholder The placeholder to use for this select menu
*
* @param placeholder - The placeholder to use for this select menu
*/
public setPlaceholder(placeholder: string) {
this.data.placeholder = placeholder;
@@ -29,7 +30,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Sets the minimum values that must be selected in the select menu
* @param minValues The minimum values that must be selected
*
* @param minValues - The minimum values that must be selected
*/
public setMinValues(minValues: number) {
this.data.min_values = minValues;
@@ -38,7 +40,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Sets the maximum values that must be selected in the select menu
* @param minValues The maximum values that must be selected
*
* @param minValues - The maximum values that must be selected
*/
public setMaxValues(maxValues: number) {
this.data.max_values = maxValues;
@@ -47,7 +50,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Sets the custom Id for this select menu
* @param customId The custom id to use for this select menu
*
* @param customId - The custom id to use for this select menu
*/
public setCustomId(customId: string) {
this.data.custom_id = customId;
@@ -56,7 +60,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Sets whether or not this select menu is disabled
* @param disabled Whether or not this select menu is disabled
*
* @param disabled - Whether or not this select menu is disabled
*/
public setDisabled(disabled = true) {
this.data.disabled = disabled;
@@ -65,8 +70,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Adds options to this select menu
* @param options The options to add to this select menu
* @returns
*
* @param options - The options to add to this select menu
*/
public addOptions(...options: RestOrArray<UnsafeSelectMenuOptionBuilder | APISelectMenuOption>) {
this.options.push(
@@ -79,7 +84,8 @@ export class UnsafeSelectMenuBuilder extends ComponentBuilder<APISelectMenuCompo
/**
* Sets the options on this select menu
* @param options The options to set on this select menu
*
* @param options - The options to set on this select menu
*/
public setOptions(...options: RestOrArray<UnsafeSelectMenuOptionBuilder | APISelectMenuOption>) {
this.options.splice(

View File

@@ -8,7 +8,8 @@ export class UnsafeSelectMenuOptionBuilder {
/**
* Sets the label of this option
* @param label The label to show on this option
*
* @param label - The label to show on this option
*/
public setLabel(label: string) {
this.data.label = label;
@@ -17,7 +18,8 @@ export class UnsafeSelectMenuOptionBuilder {
/**
* Sets the value of this option
* @param value The value of this option
*
* @param value - The value of this option
*/
public setValue(value: string) {
this.data.value = value;
@@ -26,7 +28,8 @@ export class UnsafeSelectMenuOptionBuilder {
/**
* Sets the description of this option.
* @param description The description of this option
*
* @param description - The description of this option
*/
public setDescription(description: string) {
this.data.description = description;
@@ -35,7 +38,8 @@ export class UnsafeSelectMenuOptionBuilder {
/**
* Sets whether this option is selected by default
* @param isDefault Whether this option is selected by default
*
* @param isDefault - Whether this option is selected by default
*/
public setDefault(isDefault = true) {
this.data.default = isDefault;
@@ -44,7 +48,8 @@ export class UnsafeSelectMenuOptionBuilder {
/**
* Sets the emoji to display on this option
* @param emoji The emoji to display on this option
*
* @param emoji - The emoji to display on this option
*/
public setEmoji(emoji: APIMessageComponentEmoji) {
this.data.emoji = emoji;

View File

@@ -9,7 +9,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the custom id for this text input
* @param customId The custom id of this text input
*
* @param customId - The custom id of this text input
*/
public setCustomId(customId: string) {
this.data.custom_id = customId;
@@ -18,7 +19,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the label for this text input
* @param label The label for this text input
*
* @param label - The label for this text input
*/
public setLabel(label: string) {
this.data.label = label;
@@ -27,7 +29,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the style for this text input
* @param style The style for this text input
*
* @param style - The style for this text input
*/
public setStyle(style: TextInputStyle) {
this.data.style = style;
@@ -36,7 +39,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the minimum length of text for this text input
* @param minLength The minimum length of text for this text input
*
* @param minLength - The minimum length of text for this text input
*/
public setMinLength(minLength: number) {
this.data.min_length = minLength;
@@ -45,7 +49,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the maximum length of text for this text input
* @param maxLength The maximum length of text for this text input
*
* @param maxLength - The maximum length of text for this text input
*/
public setMaxLength(maxLength: number) {
this.data.max_length = maxLength;
@@ -54,7 +59,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the placeholder of this text input
* @param placeholder The placeholder of this text input
*
* @param placeholder - The placeholder of this text input
*/
public setPlaceholder(placeholder: string) {
this.data.placeholder = placeholder;
@@ -63,7 +69,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets the value of this text input
* @param value The value for this text input
*
* @param value - The value for this text input
*/
public setValue(value: string) {
this.data.value = value;
@@ -72,7 +79,8 @@ export class UnsafeTextInputBuilder extends ComponentBuilder<APITextInputCompone
/**
* Sets whether this text input is required or not
* @param required Whether this text input is required or not
*
* @param required - Whether this text input is required or not
*/
public setRequired(required = true) {
this.data.required = required;

View File

@@ -53,7 +53,7 @@ export class ContextMenuCommandBuilder {
/**
* Sets the name
*
* @param name The name
* @param name - The name
*/
public setName(name: string) {
// Assert the name matches the conditions
@@ -67,7 +67,7 @@ export class ContextMenuCommandBuilder {
/**
* Sets the type
*
* @param type The type
* @param type - The type
*/
public setType(type: ContextMenuCommandType) {
// Assert the type is valid
@@ -83,7 +83,7 @@ export class ContextMenuCommandBuilder {
*
* **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.
*
* @param value Whether or not to enable this command by default
* @param value - Whether or not to enable this command by default
*
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
* @deprecated Use `setDefaultMemberPermissions` or `setDMPermission` instead.
@@ -102,7 +102,7 @@ export class ContextMenuCommandBuilder {
*
* **Note:** You can set this to `'0'` to disable the command by default.
*
* @param permissions The permissions bit field to set
* @param permissions - The permissions bit field to set
*
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
@@ -119,7 +119,7 @@ export class ContextMenuCommandBuilder {
* Sets if the command is available in DMs with the application, only for globally-scoped commands.
* By default, commands are visible.
*
* @param enabled If the command should be enabled in DMs
* @param enabled - If the command should be enabled in DMs
*
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
@@ -135,8 +135,8 @@ export class ContextMenuCommandBuilder {
/**
* Sets a name localization
*
* @param locale The locale to set a description for
* @param localizedName The localized description for the given locale
* @param locale - The locale to set a description for
* @param localizedName - The localized description for the given locale
*/
public setNameLocalization(locale: LocaleString, localizedName: string | null) {
if (!this.name_localizations) {
@@ -159,7 +159,7 @@ export class ContextMenuCommandBuilder {
/**
* Sets the name localizations
*
* @param localizedNames The dictionary of localized descriptions to set
* @param localizedNames - The dictionary of localized descriptions to set
*/
public setNameLocalizations(localizedNames: LocalizationMap | null) {
if (localizedNames === null) {

View File

@@ -18,7 +18,8 @@ export class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResp
/**
* Sets the title of the modal
* @param title The title of the modal
*
* @param title - The title of the modal
*/
public setTitle(title: string) {
this.data.title = title;
@@ -27,7 +28,8 @@ export class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResp
/**
* Sets the custom id of the modal
* @param customId The custom id of this modal
*
* @param customId - The custom id of this modal
*/
public setCustomId(customId: string) {
this.data.custom_id = customId;
@@ -36,7 +38,8 @@ export class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResp
/**
* Adds components to this modal
* @param components The components to add to this modal
*
* @param components - The components to add to this modal
*/
public addComponents(
...components: RestOrArray<
@@ -55,7 +58,8 @@ export class UnsafeModalBuilder implements JSONEncodable<APIModalInteractionResp
/**
* Sets the components in this modal
* @param components The components to set this modal to
*
* @param components - The components to set this modal to
*/
public setComponents(...components: RestOrArray<ActionRowBuilder<ModalActionRowComponentBuilder>>) {
this.components.splice(0, this.components.length, ...normalizeArray(components));

View File

@@ -86,7 +86,7 @@ export class SlashCommandBuilder {
*
* **Note**: If set to `false`, you will have to later `PUT` the permissions for this command.
*
* @param value Whether or not to enable this command by default
* @param value - Whether or not to enable this command by default
*
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
* @deprecated Use `setDefaultMemberPermissions` or `setDMPermission` instead.
@@ -105,7 +105,7 @@ export class SlashCommandBuilder {
*
* **Note:** You can set this to `'0'` to disable the command by default.
*
* @param permissions The permissions bit field to set
* @param permissions - The permissions bit field to set
*
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
@@ -122,7 +122,7 @@ export class SlashCommandBuilder {
* Sets if the command is available in DMs with the application, only for globally-scoped commands.
* By default, commands are visible.
*
* @param enabled If the command should be enabled in DMs
* @param enabled - If the command should be enabled in DMs
*
* @see https://discord.com/developers/docs/interactions/application-commands#permissions
*/
@@ -138,7 +138,7 @@ export class SlashCommandBuilder {
/**
* Adds a new subcommand group to this command
*
* @param input A function that returns a subcommand group builder, or an already built builder
* @param input - A function that returns a subcommand group builder, or an already built builder
*/
public addSubcommandGroup(
input:
@@ -164,7 +164,7 @@ export class SlashCommandBuilder {
/**
* Adds a new subcommand to this command
*
* @param input A function that returns a subcommand builder, or an already built builder
* @param input - A function that returns a subcommand builder, or an already built builder
*/
public addSubcommand(
input:

View File

@@ -35,7 +35,7 @@ export class SlashCommandSubcommandGroupBuilder implements ToAPIApplicationComma
/**
* Adds a new subcommand to this group
*
* @param input A function that returns a subcommand builder, or an already built builder
* @param input - A function that returns a subcommand builder, or an already built builder
*/
public addSubcommand(
input:

View File

@@ -4,13 +4,15 @@ export abstract class ApplicationCommandNumericOptionMinMaxValueMixin {
/**
* Sets the maximum number value of this option
* @param max The maximum value this option can be
*
* @param max - The maximum value this option can be
*/
public abstract setMaxValue(max: number): this;
/**
* Sets the minimum number value of this option
* @param min The minimum value this option can be
*
* @param min - The minimum value this option can be
*/
public abstract setMinValue(min: number): this;
}

View File

@@ -10,7 +10,7 @@ export abstract class ApplicationCommandOptionBase extends SharedNameAndDescript
/**
* Marks the option as required
*
* @param required If this option should be required
* @param required - If this option should be required
*/
public setRequired(required: boolean) {
// Assert that you actually passed a boolean

View File

@@ -23,7 +23,7 @@ export class ApplicationCommandOptionChannelTypesMixin {
/**
* Adds channel types to this option
*
* @param channelTypes The channel types to add
* @param channelTypes - The channel types to add
*/
public addChannelTypes(...channelTypes: ApplicationCommandOptionAllowedChannelTypes[]) {
if (this.channel_types === undefined) {

View File

@@ -21,7 +21,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends s
/**
* Adds multiple choices for this option
*
* @param choices The choices to add
* @param choices - The choices to add
*/
public addChoices(...choices: APIApplicationCommandOptionChoice<T>[]): this {
if (choices.length > 0 && this.autocomplete) {
@@ -65,7 +65,7 @@ export class ApplicationCommandOptionWithChoicesAndAutocompleteMixin<T extends s
/**
* Marks the option as autocompletable
* @param autocomplete If this option should be autocompletable
* @param autocomplete - If this option should be autocompletable
*/
public setAutocomplete(autocomplete: boolean): this {
// Assert that you actually passed a boolean

View File

@@ -10,7 +10,7 @@ export class SharedNameAndDescription {
/**
* Sets the name
*
* @param name The name
* @param name - The name
*/
public setName(name: string): this {
// Assert the name matches the conditions
@@ -24,7 +24,7 @@ export class SharedNameAndDescription {
/**
* Sets the description
*
* @param description The description
* @param description - The description
*/
public setDescription(description: string) {
// Assert the description matches the conditions
@@ -38,8 +38,8 @@ export class SharedNameAndDescription {
/**
* Sets a name localization
*
* @param locale The locale to set a description for
* @param localizedName The localized description for the given locale
* @param locale - The locale to set a description for
* @param localizedName - The localized description for the given locale
*/
public setNameLocalization(locale: LocaleString, localizedName: string | null) {
if (!this.name_localizations) {
@@ -62,7 +62,7 @@ export class SharedNameAndDescription {
/**
* Sets the name localizations
*
* @param localizedNames The dictionary of localized descriptions to set
* @param localizedNames - The dictionary of localized descriptions to set
*/
public setNameLocalizations(localizedNames: LocalizationMap | null) {
if (localizedNames === null) {
@@ -81,8 +81,8 @@ export class SharedNameAndDescription {
/**
* Sets a description localization
*
* @param locale The locale to set a description for
* @param localizedDescription The localized description for the given locale
* @param locale - The locale to set a description for
* @param localizedDescription - The localized description for the given locale
*/
public setDescriptionLocalization(locale: LocaleString, localizedDescription: string | null) {
if (!this.description_localizations) {
@@ -105,7 +105,7 @@ export class SharedNameAndDescription {
/**
* Sets the description localizations
*
* @param localizedDescriptions The dictionary of localized descriptions to set
* @param localizedDescriptions - The dictionary of localized descriptions to set
*/
public setDescriptionLocalizations(localizedDescriptions: LocalizationMap | null) {
if (localizedDescriptions === null) {

View File

@@ -17,7 +17,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a boolean option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addBooleanOption(
input: SlashCommandBooleanOption | ((builder: SlashCommandBooleanOption) => SlashCommandBooleanOption),
@@ -28,7 +28,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a user option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addUserOption(input: SlashCommandUserOption | ((builder: SlashCommandUserOption) => SlashCommandUserOption)) {
return this._sharedAddOptionMethod(input, SlashCommandUserOption);
@@ -37,7 +37,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a channel option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addChannelOption(
input: SlashCommandChannelOption | ((builder: SlashCommandChannelOption) => SlashCommandChannelOption),
@@ -48,7 +48,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a role option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addRoleOption(input: SlashCommandRoleOption | ((builder: SlashCommandRoleOption) => SlashCommandRoleOption)) {
return this._sharedAddOptionMethod(input, SlashCommandRoleOption);
@@ -57,7 +57,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds an attachment option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addAttachmentOption(
input: SlashCommandAttachmentOption | ((builder: SlashCommandAttachmentOption) => SlashCommandAttachmentOption),
@@ -68,7 +68,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a mentionable option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addMentionableOption(
input: SlashCommandMentionableOption | ((builder: SlashCommandMentionableOption) => SlashCommandMentionableOption),
@@ -79,7 +79,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a string option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addStringOption(
input:
@@ -99,7 +99,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds an integer option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addIntegerOption(
input:
@@ -119,7 +119,7 @@ export class SharedSlashCommandOptions<ShouldOmitSubcommandFunctions = true> {
/**
* Adds a number option
*
* @param input A function that returns an option builder, or an already built builder
* @param input - A function that returns an option builder, or an already built builder
*/
public addNumberOption(
input:

View File

@@ -43,7 +43,7 @@ export class UnsafeEmbedBuilder {
/**
* Adds fields to the embed (max 25)
*
* @param fields The fields to add
* @param fields - The fields to add
*/
public addFields(...fields: RestOrArray<APIEmbedField>): this {
fields = normalizeArray(fields);
@@ -55,9 +55,9 @@ export class UnsafeEmbedBuilder {
/**
* Removes, replaces, or inserts fields in the embed (max 25)
*
* @param index The index to start at
* @param deleteCount The number of fields to remove
* @param fields The replacing field objects
* @param index - The index to start at
* @param deleteCount - The number of fields to remove
* @param fields - The replacing field objects
*/
public spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this {
if (this.data.fields) this.data.fields.splice(index, deleteCount, ...fields);
@@ -67,7 +67,8 @@ export class UnsafeEmbedBuilder {
/**
* Sets the embed's fields (max 25).
* @param fields The fields to set
*
* @param fields - The fields to set
*/
public setFields(...fields: RestOrArray<APIEmbedField>) {
this.spliceFields(0, this.data.fields?.length ?? 0, ...normalizeArray(fields));
@@ -77,7 +78,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the author of this embed
*
* @param options The options for the author
* @param options - The options for the author
*/
public setAuthor(options: EmbedAuthorOptions | null): this {
if (options === null) {
@@ -92,7 +93,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the color of this embed
*
* @param color The color of the embed
* @param color - The color of the embed
*/
public setColor(color: number | RGBTuple | null): this {
if (Array.isArray(color)) {
@@ -107,7 +108,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the description of this embed
*
* @param description The description
* @param description - The description
*/
public setDescription(description: string | null): this {
this.data.description = description ?? undefined;
@@ -117,7 +118,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the footer of this embed
*
* @param options The options for the footer
* @param options - The options for the footer
*/
public setFooter(options: EmbedFooterOptions | null): this {
if (options === null) {
@@ -132,7 +133,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the image of this embed
*
* @param url The URL of the image
* @param url - The URL of the image
*/
public setImage(url: string | null): this {
this.data.image = url ? { url } : undefined;
@@ -142,7 +143,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the thumbnail of this embed
*
* @param url The URL of the thumbnail
* @param url - The URL of the thumbnail
*/
public setThumbnail(url: string | null): this {
this.data.thumbnail = url ? { url } : undefined;
@@ -152,7 +153,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the timestamp of this embed
*
* @param timestamp The timestamp or date
* @param timestamp - The timestamp or date
*/
public setTimestamp(timestamp: number | Date | null = Date.now()): this {
this.data.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;
@@ -162,7 +163,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the title of this embed
*
* @param title The title
* @param title - The title
*/
public setTitle(title: string | null): this {
this.data.title = title ?? undefined;
@@ -172,7 +173,7 @@ export class UnsafeEmbedBuilder {
/**
* Sets the URL of this embed
*
* @param url The URL
* @param url - The URL
*/
public setURL(url: string | null): this {
this.data.url = url ?? undefined;

View File

@@ -4,15 +4,15 @@ import type { Snowflake } from 'discord-api-types/globals';
/**
* Wraps the content inside a codeblock with no language
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function codeBlock<C extends string>(content: C): `\`\`\`\n${C}\`\`\``;
/**
* Wraps the content inside a codeblock with the specified language
*
* @param language The language for the codeblock
* @param content The content to wrap
* @param language - The language for the codeblock
* @param content - The content to wrap
*/
export function codeBlock<L extends string, C extends string>(language: L, content: C): `\`\`\`${L}\n${C}\`\`\``;
export function codeBlock(language: string, content?: string): string {
@@ -22,7 +22,7 @@ export function codeBlock(language: string, content?: string): string {
/**
* Wraps the content inside \`backticks\`, which formats it as inline code
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function inlineCode<C extends string>(content: C): `\`${C}\`` {
return `\`${content}\``;
@@ -31,7 +31,7 @@ export function inlineCode<C extends string>(content: C): `\`${C}\`` {
/**
* Formats the content into italic text
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function italic<C extends string>(content: C): `_${C}_` {
return `_${content}_`;
@@ -40,7 +40,7 @@ export function italic<C extends string>(content: C): `_${C}_` {
/**
* Formats the content into bold text
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function bold<C extends string>(content: C): `**${C}**` {
return `**${content}**`;
@@ -49,7 +49,7 @@ export function bold<C extends string>(content: C): `**${C}**` {
/**
* Formats the content into underscored text
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function underscore<C extends string>(content: C): `__${C}__` {
return `__${content}__`;
@@ -58,7 +58,7 @@ export function underscore<C extends string>(content: C): `__${C}__` {
/**
* Formats the content into strike-through text
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function strikethrough<C extends string>(content: C): `~~${C}~~` {
return `~~${content}~~`;
@@ -67,7 +67,7 @@ export function strikethrough<C extends string>(content: C): `~~${C}~~` {
/**
* Formats the content into a quote. This needs to be at the start of the line for Discord to format it
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function quote<C extends string>(content: C): `> ${C}` {
return `> ${content}`;
@@ -76,7 +76,7 @@ export function quote<C extends string>(content: C): `> ${C}` {
/**
* Formats the content into a block quote. This needs to be at the start of the line for Discord to format it
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function blockQuote<C extends string>(content: C): `>>> ${C}` {
return `>>> ${content}`;
@@ -85,14 +85,14 @@ export function blockQuote<C extends string>(content: C): `>>> ${C}` {
/**
* Wraps the URL into `<>`, which stops it from embedding
*
* @param url The URL to wrap
* @param url - The URL to wrap
*/
export function hideLinkEmbed<C extends string>(url: C): `<${C}>`;
/**
* Wraps the URL into `<>`, which stops it from embedding
*
* @param url The URL to wrap
* @param url - The URL to wrap
*/
export function hideLinkEmbed(url: URL): `<${string}>`;
export function hideLinkEmbed(url: string | URL) {
@@ -103,25 +103,25 @@ export function hideLinkEmbed(url: string | URL) {
/**
* Formats the content and the URL into a masked URL
*
* @param content The content to display
* @param url The URL the content links to
* @param content - The content to display
* @param url - The URL the content links to
*/
export function hyperlink<C extends string>(content: C, url: URL): `[${C}](${string})`;
/**
* Formats the content and the URL into a masked URL
*
* @param content The content to display
* @param url The URL the content links to
* @param content - The content to display
* @param url - The URL the content links to
*/
export function hyperlink<C extends string, U extends string>(content: C, url: U): `[${C}](${U})`;
/**
* Formats the content and the URL into a masked URL
*
* @param content The content to display
* @param url The URL the content links to
* @param title The title shown when hovering on the masked link
* @param content - The content to display
* @param url - The URL the content links to
* @param title - The title shown when hovering on the masked link
*/
export function hyperlink<C extends string, T extends string>(
content: C,
@@ -132,9 +132,9 @@ export function hyperlink<C extends string, T extends string>(
/**
* Formats the content and the URL into a masked URL
*
* @param content The content to display
* @param url The URL the content links to
* @param title The title shown when hovering on the masked link
* @param content - The content to display
* @param url - The URL the content links to
* @param title - The title shown when hovering on the masked link
*/
export function hyperlink<C extends string, U extends string, T extends string>(
content: C,
@@ -149,7 +149,7 @@ export function hyperlink(content: string, url: string | URL, title?: string) {
/**
* Wraps the content inside spoiler (hidden text)
*
* @param content The content to wrap
* @param content - The content to wrap
*/
export function spoiler<C extends string>(content: C): `||${C}||` {
return `||${content}||`;
@@ -158,7 +158,7 @@ export function spoiler<C extends string>(content: C): `||${C}||` {
/**
* Formats a user ID into a user mention
*
* @param userId The user ID to format
* @param userId - The user ID to format
*/
export function userMention<C extends Snowflake>(userId: C): `<@${C}>` {
return `<@${userId}>`;
@@ -167,7 +167,7 @@ export function userMention<C extends Snowflake>(userId: C): `<@${C}>` {
/**
* Formats a channel ID into a channel mention
*
* @param channelId The channel ID to format
* @param channelId - The channel ID to format
*/
export function channelMention<C extends Snowflake>(channelId: C): `<#${C}>` {
return `<#${channelId}>`;
@@ -176,7 +176,7 @@ export function channelMention<C extends Snowflake>(channelId: C): `<#${C}>` {
/**
* Formats a role ID into a role mention
*
* @param roleId The role ID to format
* @param roleId - The role ID to format
*/
export function roleMention<C extends Snowflake>(roleId: C): `<@&${C}>` {
return `<@&${roleId}>`;
@@ -185,23 +185,23 @@ export function roleMention<C extends Snowflake>(roleId: C): `<@&${C}>` {
/**
* Formats an emoji ID into a fully qualified emoji identifier
*
* @param emojiId The emoji ID to format
* @param emojiId - The emoji ID to format
*/
export function formatEmoji<C extends Snowflake>(emojiId: C, animated?: false): `<:_:${C}>`;
/**
* Formats an emoji ID into a fully qualified emoji identifier
*
* @param emojiId The emoji ID to format
* @param animated Whether the emoji is animated or not. Defaults to `false`
* @param emojiId - The emoji ID to format
* @param animated - Whether the emoji is animated or not. Defaults to `false`
*/
export function formatEmoji<C extends Snowflake>(emojiId: C, animated?: true): `<a:_:${C}>`;
/**
* Formats an emoji ID into a fully qualified emoji identifier
*
* @param emojiId The emoji ID to format
* @param animated Whether the emoji is animated or not. Defaults to `false`
* @param emojiId - The emoji ID to format
* @param animated - Whether the emoji is animated or not. Defaults to `false`
*/
export function formatEmoji<C extends Snowflake>(emojiId: C, animated = false): `<a:_:${C}>` | `<:_:${C}>` {
return `<${animated ? 'a' : ''}:_:${emojiId}>`;
@@ -210,30 +210,30 @@ export function formatEmoji<C extends Snowflake>(emojiId: C, animated = false):
/**
* Formats a date into a short date-time string
*
* @param date The date to format, defaults to the current time
* @param date - The date to format, defaults to the current time
*/
export function time(date?: Date): `<t:${bigint}>`;
/**
* Formats a date given a format style
*
* @param date The date to format
* @param style The style to use
* @param date - The date to format
* @param style - The style to use
*/
export function time<S extends TimestampStylesString>(date: Date, style: S): `<t:${bigint}:${S}>`;
/**
* Formats the given timestamp into a short date-time string
*
* @param seconds The time to format, represents an UNIX timestamp in seconds
* @param seconds - The time to format, represents an UNIX timestamp in seconds
*/
export function time<C extends number>(seconds: C): `<t:${C}>`;
/**
* Formats the given timestamp into a short date-time string
*
* @param seconds The time to format, represents an UNIX timestamp in seconds
* @param style The style to use
* @param seconds - The time to format, represents an UNIX timestamp in seconds
* @param style - The style to use
*/
export function time<C extends number, S extends TimestampStylesString>(seconds: C, style: S): `<t:${C}:${S}>`;
export function time(timeOrSeconds?: number | Date, style?: TimestampStylesString): string {

View File

@@ -7,7 +7,7 @@ export interface Equatable<T> {
/**
* Indicates if an object is equatable or not.
* @param maybeEquatable The object to check against
* @param maybeEquatable - The object to check against
*/
export function isEquatable(maybeEquatable: unknown): maybeEquatable is Equatable<unknown> {
return maybeEquatable !== null && typeof maybeEquatable === 'object' && 'equals' in maybeEquatable;

View File

@@ -7,7 +7,7 @@ export interface JSONEncodable<T> {
/**
* Indicates if an object is encodable or not.
* @param maybeEncodable The object to check against
* @param maybeEncodable - The object to check against
*/
export function isJSONEncodable(maybeEncodable: unknown): maybeEncodable is JSONEncodable<unknown> {
return maybeEncodable !== null && typeof maybeEncodable === 'object' && 'toJSON' in maybeEncodable;