Skip to content
This repository has been archived by the owner on Dec 22, 2023. It is now read-only.

Commit

Permalink
refactor: tsdocs
Browse files Browse the repository at this point in the history
  • Loading branch information
DanieliusDev committed Jan 2, 2023
1 parent 9a2544a commit dd4a1e9
Show file tree
Hide file tree
Showing 93 changed files with 3,139 additions and 2,417 deletions.
11 changes: 11 additions & 0 deletions .changeset/weak-rings-divide.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,11 @@
---
'@guildedts/builders': patch
'@guildedts/framework': patch
'guilded-api-typings': patch
'guilded.ts': patch
'@guildedts/rest': patch
'@guildedts/util': patch
'@guildedts/ws': patch
---

refactor: tsdocs
148 changes: 73 additions & 75 deletions packages/builders/src/Embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -9,35 +9,57 @@ import {
import { ColorResolvable, resolveColor } from '@guildedts/util';

/**
* The embed builder for Guilded embeds.
* The embed builder for Guilded embeds
* @example
* new Embed()
* .setTitle('Embed Title')
* .setDescription('This is the embed description.');
*/
export class Embed {
/** The title of the embed. */
/**
* The title of the embed
*/
title?: string;
/** The description of the embed. */
/**
* The description of the embed
*/
description?: string;
/** The URL of the embed. */
/**
* The URL of the embed
*/
url?: string;
/** The color of the embed. */
/**
* The color of the embed
*/
color?: number;
/** The footer of the embed. */
/**
* The footer of the embed
*/
footer?: APIEmbedFooter;
/** The timestamp of the embed. */
/**
* The timestamp of the embed
*/
timestamp?: Date;
/** The thumbnail of the embed. */
/**
* The thumbnail of the embed
*/
thumbnail?: APIEmbedThumbnail;
/** The image of the embed. */
/**
* The image of the embed
*/
image?: APIEmbedImage;
/** The author of the embed. */
/**
* The author of the embed
*/
author?: APIEmbedAuthor;
/** The fields of the embed. */
/**
* The fields of the embed
*/
fields: APIEmbedField[];

/** @param data The initial data of the embed. */
/**
* @param data The data of the embed
*/
constructor(data: APIEmbed = {}) {
this.title = data.title;
this.description = data.description;
Expand All @@ -52,49 +74,46 @@ export class Embed {
}

/**
* Set the title of the embed.
* @param title The title of the embed.
* @returns This embed builder.
* @example embed.setTitle('Embed Title');
* Set the title of the embed
* @param title The title of the embed
* @returns This embed builder
*/
setTitle(title?: string) {
this.title = title;
return this;
}

/**
* Set the description of the embed.
* @param description The description of the embed.
* @returns The embed builder.
* @example embed.setDescription('This is the embed description.');
* Set the description of the embed
* @param description The description of the embed
* @returns The embed builder
*/
setDescription(description?: string) {
this.description = description;
return this;
}

/**
* Set the URL of the embed.
* @param url The URL of the embed.
* @returns The embed builder.
* @example embed.setUrl('https://example.com');
* Set the URL of the embed
* @param url The URL of the embed
* @returns The embed builder
*/
setUrl(url?: string) {
this.url = url;
return this;
}

/**
* Set the color of the embed.
* @param color The color of the embed.
* @returns The embed builder.
* Set the color of the embed
* @param color The color of the embed
* @returns The embed builder
* @example
* // Set the color of the embed with a hex color.
* // Set the color of the embed with a hex color
* embed.setColor(0xFFFFFF);
* embed.setColor('#FFFFFF');
* // Set the color of the embed with a preset color.
* // Set the color of the embed with a preset color
* embed.setColor('WHITE');
* // Set the color of the embed with RGB values.
* // Set the color of the embed with RGB values
* embed.setColor([255, 255, 255]);
*/
setColor(color?: ColorResolvable) {
Expand All @@ -103,93 +122,72 @@ export class Embed {
}

/**
* Set the footer of the embed.
* @param text The text of the footer.
* @param iconUrl The icon URL of the footer.
* @returns The embed builder.
* @example embed.setFooter('Footer Text', 'https://example.com');
* Set the footer of the embed
* @param text The text of the embed footer
* @param iconUrl The icon URL of the embed footer
* @returns The embed builder
*/
setFooter(text?: string, iconUrl?: string) {
this.footer = text ? { text, icon_url: iconUrl } : undefined;
return this;
}

/**
* Set the timestamp of the embed.
* @param timestamp The timestamp of the embed.
* @returns The embed builder.
* @example
* // Set the timestamp of the embed with an ISO 8601 date.
* embed.setTimestamp('2022-01-01T00:00:00.000Z');
* // Set the timestamp of the embed with a number of milliseconds since the epoch.
* embed.setTimestamp(1640995200000);
* // Set the timestamp of the embed with a Date object.
* embed.setTimestamp(new Date('2022-01-01T00:00:00.000Z'));
* Set the timestamp of the embed
* @param timestamp The timestamp of the embed
* @returns The embed builder
*/
setTimestamp(timestamp?: string | number | Date) {
this.timestamp = new Date(timestamp ?? Date.now());
return this;
}

/**
* Set the thumbnail of the embed.
* @param thumbnailUrl The thumbnail URL of the embed.
* @returns The embed builder.
* @example embed.setThumbnail('https://example.com');
* Set the thumbnail of the embed
* @param thumbnailUrl The thumbnail URL of the embed
* @returns The embed builder
*/
setThumbnail(thumbnailUrl?: string) {
if (thumbnailUrl) this.thumbnail = { url: thumbnailUrl };
return this;
}

/**
* Set the image of the embed.
* @param imageUrl The image URL of the embed.
* @returns The embed builder.
* @example embed.setImage('https://example.com');
* Set the image of the embed
* @param imageUrl The image URL of the embed
* @returns The embed builder
*/
setImage(imageUrl?: string) {
if (imageUrl) this.image = { url: imageUrl };
return this;
}

/**
* Set the author of the embed.
* @param author The author of the embed.
* @returns The embed builder.
* @example
* // Set the author of the embed with a name.
* embed.setAuthor('Author Name');
* // Set the author of the embed with a name, icon, and URL.
* embed.setAuthor({ name: 'Author Name', icon_url: 'https://example.com', url: 'https://example.com' });
* Set the author of the embed
* @param author The author of the embed
* @returns The embed builder
*/
setAuthor(author?: string | APIEmbedAuthor) {
this.author = typeof author === 'string' ? { name: author } : author;
return this;
}

/**
* Add a field to the embed.
* @param name The name of the field.
* @param value The value of the field.
* @param inline Whether the field is inline.
* @returns The embed builder.
* @example
* // Add a field to the embed.
* embed.addField('Field Name', 'Field Value');
* // Add a inline field to the embed.
* embed.addField('Field Name', 'Field Value', true);
* Add a field to the embed
* @param name The name of the embed field
* @param value The value of the embed field
* @param inline Whether the embed field is inline
* @returns The embed builder
*/
addField(name: string, value: string, inline?: boolean) {
this.fields.push({ name, value, inline });
return this;
}

/**
* Set the fields of the embed.
* @param fields The fields of the embed.
* @returns The embed builder.
* @example embed.setFields([{ name: 'Field Name', value: 'Field Value' }]);
* Set the fields of the embed
* @param fields The fields of the embed
* @returns The embed builder
*/
setFields(fields: APIEmbedField[] = []) {
this.fields = fields;
Expand Down
58 changes: 29 additions & 29 deletions packages/builders/src/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -2,57 +2,57 @@ export * from './Embed';
export * from '@guildedts/util';

/**
* Create bold text.
* @param text The text to be formatted.
* @returns The formatted text.
* Create bold text
* @param text The text
* @returns The formatted text
* @example bold('bold text'); // '**bold text**'
*/
export const bold = <T extends string>(text: T) => `**${text}**` as const;

/**
* Create italic text.
* @param text The text to be formatted.
* @returns The formatted text.
* Create italic text
* @param text The text
* @returns The formatted text
* @example italic('italic text'); // '*italic text*'
*/
export const italic = <T extends string>(text: T) => `*${text}*` as const;

/**
* Create a spoiler.
* @param text The text to be formatted.
* @returns The formatted text.
* Create a spoiler
* @param text The text
* @returns The formatted text
* @example spoiler('spoiler text'); // '||spoiler text||'
*/
export const spoiler = <T extends string>(text: T) => `||${text}||` as const;

/**
* Underline text.
* @param text The text to be formatted.
* @returns The formatted text.
* Underline text
* @param text The text
* @returns The formatted text
* @example underline('underlined text'); // '__underlined text__'
*/
export const underline = <T extends string>(text: T) => `__${text}__` as const;

/**
* Strikethrough text.
* @param text The text to be formatted.
* @returns The formatted text.
* Strikethrough text
* @param text The text
* @returns The formatted text
* @example strikethrough('strikethrough text'); // '~~strikethrough text~~'
*/
export const strikeThrough = <T extends string>(text: T) => `~~${text}~~` as const;

/**
* Create inline code.
* @param text The text to be formatted.
* @returns The formatted text.
* Create inline code
* @param text The text
* @returns The formatted text
* @example inlineCode('inline code'); // '`inline code`'
*/
export const inlineCode = <T extends string>(text: T) => `\`${text}\`` as const;

/**
* Create a divider
* @param newLine Whether to create a new line.
* @returns The formatted text.
* @param newLine Whether to create a new line
* @returns The formatted text
* @example
* // Create a divider
* divider(); // '---'
Expand All @@ -63,25 +63,25 @@ export const divider = <NL extends boolean>(newLine = false as NL) =>
(newLine ? '\n---\n' : '---') as NL extends true ? '\n---\n' : '---';

/**
* Create a big heading.
* @param text The text to be formatted.
* @returns The formatted text.
* Create a big heading
* @param text The text
* @returns The formatted text
* @example h1('big heading'); // '# big heading'
*/
export const h1 = <T extends string>(text: T) => `# ${text}` as const;

/**
* Create a medium heading.
* @param text The text to be formatted.
* @returns The formatted text.
* Create a medium heading
* @param text The text
* @returns The formatted text
* @example h2('medium heading'); // '## medium heading'
*/
export const h2 = <T extends string>(text: T) => `## ${text}` as const;

/**
* Create a user mention.
* @param userId The ID of the user to mention.
* @returns The formatted text.
* Create a user mention
* @param userId The ID of the user
* @returns The formatted text
* @example userMention('abc'); // '<@abc>'
*/
export const userMention = <U extends string>(userId: U) => `<@${userId}>` as const;
Loading

1 comment on commit dd4a1e9

@vercel
Copy link

@vercel vercel bot commented on dd4a1e9 Jan 2, 2023

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Please sign in to comment.