Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor(embed): mark properties as readonly #7332

Merged
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
46 changes: 23 additions & 23 deletions packages/builders/src/messages/embed/Embed.ts
Original file line number Diff line number Diff line change
Expand Up @@ -41,62 +41,62 @@ export class Embed implements APIEmbed {
/**
* An array of fields of this embed
*/
public fields: APIEmbedField[];
public readonly fields: APIEmbedField[];

/**
* The embed title
*/
public title?: string;
public readonly title?: string;

/**
* The embed description
*/
public description?: string;
public readonly description?: string;

/**
* The embed url
*/
public url?: string;
public readonly url?: string;

/**
* The embed color
*/
public color?: number;
public readonly color?: number;

/**
* The timestamp of the embed in the ISO format
*/
public timestamp?: string;
public readonly timestamp?: string;

/**
* The embed thumbnail data
*/
public thumbnail?: APIEmbedThumbnail;
public readonly thumbnail?: APIEmbedThumbnail;

/**
* The embed image data
*/
public image?: APIEmbedImage;
public readonly image?: APIEmbedImage;

/**
* Received video data
*/
public video?: APIEmbedVideo;
public readonly video?: APIEmbedVideo;

/**
* The embed author data
*/
public author?: APIEmbedAuthor;
public readonly author?: APIEmbedAuthor;

/**
* Received data about the embed provider
*/
public provider?: APIEmbedProvider;
public readonly provider?: APIEmbedProvider;

/**
* The embed footer data
*/
public footer?: APIEmbedFooter;
public readonly footer?: APIEmbedFooter;

public constructor(data: APIEmbed = {}) {
this.title = data.title;
Expand Down Expand Up @@ -177,7 +177,7 @@ export class Embed implements APIEmbed {
*/
public setAuthor(options: AuthorOptions | null): this {
if (options === null) {
this.author = undefined;
Reflect.set(this, 'author', undefined);
return this;
}

Expand All @@ -187,7 +187,7 @@ export class Embed implements APIEmbed {
urlPredicate.parse(iconURL);
urlPredicate.parse(url);

this.author = { name, url, icon_url: iconURL };
Reflect.set(this, 'author', { name, url, icon_url: iconURL });
return this;
}

Expand All @@ -200,7 +200,7 @@ export class Embed implements APIEmbed {
// Data assertions
colorPredicate.parse(color);

this.color = color ?? undefined;
Reflect.set(this, 'color', color ?? undefined);
return this;
}

Expand All @@ -213,7 +213,7 @@ export class Embed implements APIEmbed {
// Data assertions
descriptionPredicate.parse(description);

this.description = description ?? undefined;
Reflect.set(this, 'description', description ?? undefined);
return this;
}

Expand All @@ -224,7 +224,7 @@ export class Embed implements APIEmbed {
*/
public setFooter(options: FooterOptions | null): this {
if (options === null) {
this.footer = undefined;
Reflect.set(this, 'footer', undefined);
return this;
}

Expand All @@ -233,7 +233,7 @@ export class Embed implements APIEmbed {
footerTextPredicate.parse(text);
urlPredicate.parse(iconURL);

this.footer = { text, icon_url: iconURL };
Reflect.set(this, 'footer', { text, icon_url: iconURL });
return this;
}

Expand All @@ -246,7 +246,7 @@ export class Embed implements APIEmbed {
// Data assertions
urlPredicate.parse(url);

this.image = url ? { url } : undefined;
Reflect.set(this, 'image', url ? { url } : undefined);
return this;
}

Expand All @@ -259,7 +259,7 @@ export class Embed implements APIEmbed {
// Data assertions
urlPredicate.parse(url);

this.thumbnail = url ? { url } : undefined;
Reflect.set(this, 'thumbnail', url ? { url } : undefined);
return this;
}

Expand All @@ -272,7 +272,7 @@ export class Embed implements APIEmbed {
// Data assertions
timestampPredicate.parse(timestamp);

this.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;
Reflect.set(this, 'timestamp', timestamp ? new Date(timestamp).toISOString() : undefined);
return this;
}

Expand All @@ -285,7 +285,7 @@ export class Embed implements APIEmbed {
// Data assertions
titlePredicate.parse(title);

this.title = title ?? undefined;
Reflect.set(this, 'title', title ?? undefined);
return this;
}

Expand All @@ -298,7 +298,7 @@ export class Embed implements APIEmbed {
// Data assertions
urlPredicate.parse(url);

this.url = url ?? undefined;
Reflect.set(this, 'url', url ?? undefined);
return this;
}

Expand Down