added all files
This commit is contained in:
+23
@@ -0,0 +1,23 @@
|
||||
import type { APIEmbedField } from 'discord-api-types/v9';
|
||||
export declare const fieldNamePredicate: import("ow").StringPredicate;
|
||||
export declare const fieldValuePredicate: import("ow").StringPredicate;
|
||||
export declare const fieldInlinePredicate: import("ow").BooleanPredicate & import("ow").BasePredicate<boolean | undefined>;
|
||||
export declare const embedFieldPredicate: import("ow").ObjectPredicate<{
|
||||
name: string;
|
||||
value: string;
|
||||
inline: boolean | undefined;
|
||||
}>;
|
||||
export declare const embedFieldsArrayPredicate: import("ow").ArrayPredicate<{
|
||||
name: string;
|
||||
value: string;
|
||||
inline: boolean | undefined;
|
||||
}>;
|
||||
export declare function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void;
|
||||
export declare const authorNamePredicate: import("ow").AnyPredicate<string | null>;
|
||||
export declare const urlPredicate: import("ow").AnyPredicate<string | null | undefined>;
|
||||
export declare const colorPredicate: import("ow").AnyPredicate<number | null>;
|
||||
export declare const descriptionPredicate: import("ow").AnyPredicate<string | null>;
|
||||
export declare const footerTextPredicate: import("ow").AnyPredicate<string | null>;
|
||||
export declare const timestampPredicate: import("ow").AnyPredicate<number | Date | null>;
|
||||
export declare const titlePredicate: import("ow").AnyPredicate<string | null>;
|
||||
//# sourceMappingURL=Assertions.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Assertions.d.ts","sourceRoot":"/","sources":["messages/embed/Assertions.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EAAE,aAAa,EAAE,MAAM,sBAAsB,CAAC;AAG1D,eAAO,MAAM,kBAAkB,8BAAwC,CAAC;AAExE,eAAO,MAAM,mBAAmB,8BAAyC,CAAC;AAE1E,eAAO,MAAM,oBAAoB,iFAAsB,CAAC;AAExD,eAAO,MAAM,mBAAmB;;;;EAI9B,CAAC;AAEH,eAAO,MAAM,yBAAyB;;;;EAAuC,CAAC;AAE9E,wBAAgB,mBAAmB,CAAC,MAAM,EAAE,aAAa,EAAE,EAAE,YAAY,EAAE,MAAM,GAAG,IAAI,CAEvF;AAED,eAAO,MAAM,mBAAmB,0CAAsC,CAAC;AAEvE,eAAO,MAAM,YAAY,sDAA4C,CAAC;AAEtE,eAAO,MAAM,cAAc,0CAA6E,CAAC;AAEzG,eAAO,MAAM,oBAAoB,0CAA0D,CAAC;AAE5F,eAAO,MAAM,mBAAmB,0CAA0D,CAAC;AAE3F,eAAO,MAAM,kBAAkB,iDAAsC,CAAC;AAEtE,eAAO,MAAM,cAAc,0CAAsC,CAAC"}
|
||||
+26
@@ -0,0 +1,26 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.titlePredicate = exports.timestampPredicate = exports.footerTextPredicate = exports.descriptionPredicate = exports.colorPredicate = exports.urlPredicate = exports.authorNamePredicate = exports.validateFieldLength = exports.embedFieldsArrayPredicate = exports.embedFieldPredicate = exports.fieldInlinePredicate = exports.fieldValuePredicate = exports.fieldNamePredicate = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const ow_1 = tslib_1.__importDefault(require("ow"));
|
||||
exports.fieldNamePredicate = ow_1.default.string.minLength(1).maxLength(256);
|
||||
exports.fieldValuePredicate = ow_1.default.string.minLength(1).maxLength(1024);
|
||||
exports.fieldInlinePredicate = ow_1.default.optional.boolean;
|
||||
exports.embedFieldPredicate = ow_1.default.object.exactShape({
|
||||
name: exports.fieldNamePredicate,
|
||||
value: exports.fieldValuePredicate,
|
||||
inline: exports.fieldInlinePredicate,
|
||||
});
|
||||
exports.embedFieldsArrayPredicate = ow_1.default.array.ofType(exports.embedFieldPredicate);
|
||||
function validateFieldLength(fields, amountAdding) {
|
||||
ow_1.default(fields.length + amountAdding, 'field amount', ow_1.default.number.lessThanOrEqual(25));
|
||||
}
|
||||
exports.validateFieldLength = validateFieldLength;
|
||||
exports.authorNamePredicate = ow_1.default.any(exports.fieldNamePredicate, ow_1.default.null);
|
||||
exports.urlPredicate = ow_1.default.any(ow_1.default.string.url, ow_1.default.nullOrUndefined);
|
||||
exports.colorPredicate = ow_1.default.any(ow_1.default.number.greaterThanOrEqual(0).lessThanOrEqual(0xffffff), ow_1.default.null);
|
||||
exports.descriptionPredicate = ow_1.default.any(ow_1.default.string.minLength(1).maxLength(4096), ow_1.default.null);
|
||||
exports.footerTextPredicate = ow_1.default.any(ow_1.default.string.minLength(1).maxLength(2048), ow_1.default.null);
|
||||
exports.timestampPredicate = ow_1.default.any(ow_1.default.number, ow_1.default.date, ow_1.default.null);
|
||||
exports.titlePredicate = ow_1.default.any(exports.fieldNamePredicate, ow_1.default.null);
|
||||
//# sourceMappingURL=Assertions.js.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Assertions.js","sourceRoot":"/","sources":["messages/embed/Assertions.ts"],"names":[],"mappings":";;;;AACA,oDAAoB;AAEP,QAAA,kBAAkB,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC;AAE3D,QAAA,mBAAmB,GAAG,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,CAAC;AAE7D,QAAA,oBAAoB,GAAG,YAAE,CAAC,QAAQ,CAAC,OAAO,CAAC;AAE3C,QAAA,mBAAmB,GAAG,YAAE,CAAC,MAAM,CAAC,UAAU,CAAC;IACvD,IAAI,EAAE,0BAAkB;IACxB,KAAK,EAAE,2BAAmB;IAC1B,MAAM,EAAE,4BAAoB;CAC5B,CAAC,CAAC;AAEU,QAAA,yBAAyB,GAAG,YAAE,CAAC,KAAK,CAAC,MAAM,CAAC,2BAAmB,CAAC,CAAC;AAE9E,SAAgB,mBAAmB,CAAC,MAAuB,EAAE,YAAoB;IAChF,YAAE,CAAC,MAAM,CAAC,MAAM,GAAG,YAAY,EAAE,cAAc,EAAE,YAAE,CAAC,MAAM,CAAC,eAAe,CAAC,EAAE,CAAC,CAAC,CAAC;AACjF,CAAC;AAFD,kDAEC;AAEY,QAAA,mBAAmB,GAAG,YAAE,CAAC,GAAG,CAAC,0BAAkB,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE1D,QAAA,YAAY,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,GAAG,EAAE,YAAE,CAAC,eAAe,CAAC,CAAC;AAEzD,QAAA,cAAc,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,kBAAkB,CAAC,CAAC,CAAC,CAAC,eAAe,CAAC,QAAQ,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE5F,QAAA,oBAAoB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE/E,QAAA,mBAAmB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,CAAC,SAAS,CAAC,CAAC,CAAC,CAAC,SAAS,CAAC,IAAI,CAAC,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAE9E,QAAA,kBAAkB,GAAG,YAAE,CAAC,GAAG,CAAC,YAAE,CAAC,MAAM,EAAE,YAAE,CAAC,IAAI,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC;AAEzD,QAAA,cAAc,GAAG,YAAE,CAAC,GAAG,CAAC,0BAAkB,EAAE,YAAE,CAAC,IAAI,CAAC,CAAC","sourcesContent":["import type { APIEmbedField } from 'discord-api-types/v9';\nimport ow from 'ow';\n\nexport const fieldNamePredicate = ow.string.minLength(1).maxLength(256);\n\nexport const fieldValuePredicate = ow.string.minLength(1).maxLength(1024);\n\nexport const fieldInlinePredicate = ow.optional.boolean;\n\nexport const embedFieldPredicate = ow.object.exactShape({\n\tname: fieldNamePredicate,\n\tvalue: fieldValuePredicate,\n\tinline: fieldInlinePredicate,\n});\n\nexport const embedFieldsArrayPredicate = ow.array.ofType(embedFieldPredicate);\n\nexport function validateFieldLength(fields: APIEmbedField[], amountAdding: number): void {\n\tow(fields.length + amountAdding, 'field amount', ow.number.lessThanOrEqual(25));\n}\n\nexport const authorNamePredicate = ow.any(fieldNamePredicate, ow.null);\n\nexport const urlPredicate = ow.any(ow.string.url, ow.nullOrUndefined);\n\nexport const colorPredicate = ow.any(ow.number.greaterThanOrEqual(0).lessThanOrEqual(0xffffff), ow.null);\n\nexport const descriptionPredicate = ow.any(ow.string.minLength(1).maxLength(4096), ow.null);\n\nexport const footerTextPredicate = ow.any(ow.string.minLength(1).maxLength(2048), ow.null);\n\nexport const timestampPredicate = ow.any(ow.number, ow.date, ow.null);\n\nexport const titlePredicate = ow.any(fieldNamePredicate, ow.null);\n"]}
|
||||
+140
@@ -0,0 +1,140 @@
|
||||
import type { APIEmbed, APIEmbedAuthor, APIEmbedField, APIEmbedFooter, APIEmbedImage, APIEmbedProvider, APIEmbedThumbnail, APIEmbedVideo } from 'discord-api-types/v9';
|
||||
export interface AuthorOptions {
|
||||
name: string;
|
||||
url?: string;
|
||||
iconURL?: string;
|
||||
}
|
||||
export interface FooterOptions {
|
||||
text: string;
|
||||
iconURL?: string;
|
||||
}
|
||||
/**
|
||||
* Represents an embed in a message (image/video preview, rich embed, etc.)
|
||||
*/
|
||||
export declare class Embed implements APIEmbed {
|
||||
/**
|
||||
* An array of fields of this embed.
|
||||
*/
|
||||
fields: APIEmbedField[];
|
||||
/**
|
||||
* The embed title.
|
||||
*/
|
||||
title?: string;
|
||||
/**
|
||||
* The embed description.
|
||||
*/
|
||||
description?: string;
|
||||
/**
|
||||
* The embed url.
|
||||
*/
|
||||
url?: string;
|
||||
/**
|
||||
* The embed color.
|
||||
*/
|
||||
color?: number;
|
||||
/**
|
||||
* The timestamp of the embed in the ISO format.
|
||||
*/
|
||||
timestamp?: string;
|
||||
/**
|
||||
* The embed thumbnail data.
|
||||
*/
|
||||
thumbnail?: APIEmbedThumbnail;
|
||||
/**
|
||||
* The embed image data.
|
||||
*/
|
||||
image?: APIEmbedImage;
|
||||
/**
|
||||
* Received video data.
|
||||
*/
|
||||
video?: APIEmbedVideo;
|
||||
/**
|
||||
* The embed author data.
|
||||
*/
|
||||
author?: APIEmbedAuthor;
|
||||
/**
|
||||
* Received data about the embed provider.
|
||||
*/
|
||||
provider?: APIEmbedProvider;
|
||||
/**
|
||||
* The embed footer data.
|
||||
*/
|
||||
footer?: APIEmbedFooter;
|
||||
constructor(data?: APIEmbed);
|
||||
/**
|
||||
* The accumulated length for the embed title, description, fields, footer text, and author name.
|
||||
*/
|
||||
get length(): number;
|
||||
/**
|
||||
* Adds a field to the embed (max 25).
|
||||
* @param field The field to add.
|
||||
*/
|
||||
addField(field: APIEmbedField): this;
|
||||
/**
|
||||
* Adds fields to the embed (max 25).
|
||||
* @param fields The fields to add.
|
||||
*/
|
||||
addFields(...fields: APIEmbedField[]): this;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
spliceFields(index: number, deleteCount: number, ...fields: APIEmbedField[]): this;
|
||||
/**
|
||||
* Sets the author of this embed.
|
||||
* @param options The options for the author.
|
||||
*/
|
||||
setAuthor(options: AuthorOptions | null): this;
|
||||
/**
|
||||
* Sets the color of this embed.
|
||||
* @param color The color of the embed.
|
||||
*/
|
||||
setColor(color: number | null): this;
|
||||
/**
|
||||
* Sets the description of this embed.
|
||||
* @param description The description.
|
||||
*/
|
||||
setDescription(description: string | null): this;
|
||||
/**
|
||||
* Sets the footer of this embed.
|
||||
* @param options The options for the footer.
|
||||
*/
|
||||
setFooter(options: FooterOptions | null): this;
|
||||
/**
|
||||
* Sets the image of this embed.
|
||||
* @param url The URL of the image.
|
||||
*/
|
||||
setImage(url: string | null): this;
|
||||
/**
|
||||
* Sets the thumbnail of this embed.
|
||||
* @param url The URL of the thumbnail.
|
||||
*/
|
||||
setThumbnail(url: string | null): this;
|
||||
/**
|
||||
* Sets the timestamp of this embed.
|
||||
* @param timestamp The timestamp or date.
|
||||
*/
|
||||
setTimestamp(timestamp?: number | Date | null): this;
|
||||
/**
|
||||
* Sets the title of this embed.
|
||||
* @param title The title.
|
||||
*/
|
||||
setTitle(title: string | null): this;
|
||||
/**
|
||||
* Sets the URL of this embed.
|
||||
* @param url The URL.
|
||||
*/
|
||||
setURL(url: string | null): this;
|
||||
/**
|
||||
* Transforms the embed to a plain object.
|
||||
*/
|
||||
toJSON(): APIEmbed;
|
||||
/**
|
||||
* Normalizes field input and resolves strings.
|
||||
* @param fields Fields to normalize.
|
||||
*/
|
||||
static normalizeFields(...fields: APIEmbedField[]): APIEmbedField[];
|
||||
}
|
||||
//# sourceMappingURL=Embed.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"Embed.d.ts","sourceRoot":"/","sources":["messages/embed/Embed.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,EACX,QAAQ,EACR,cAAc,EACd,aAAa,EACb,cAAc,EACd,aAAa,EACb,gBAAgB,EAChB,iBAAiB,EACjB,aAAa,EACb,MAAM,sBAAsB,CAAC;AAiB9B,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,GAAG,CAAC,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED,MAAM,WAAW,aAAa;IAC7B,IAAI,EAAE,MAAM,CAAC;IACb,OAAO,CAAC,EAAE,MAAM,CAAC;CACjB;AAED;;GAEG;AACH,qBAAa,KAAM,YAAW,QAAQ;IACrC;;OAEG;IACI,MAAM,EAAE,aAAa,EAAE,CAAC;IAE/B;;OAEG;IACI,KAAK,CAAC,EAAE,MAAM,CAAC;IAEtB;;OAEG;IACI,WAAW,CAAC,EAAE,MAAM,CAAC;IAE5B;;OAEG;IACI,GAAG,CAAC,EAAE,MAAM,CAAC;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AAE,MAAM,GAAG,IAAI,GAAG,IAAiB,GAAG,IAAI;IAQvE;;;OAGG;IACI,QAAQ,CAAC,KAAK,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQ3C;;;OAGG;IACI,MAAM,CAAC,GAAG,EAAE,MAAM,GAAG,IAAI,GAAG,IAAI;IAQvC;;OAEG;IACI,MAAM,IAAI,QAAQ;IAIzB;;;OAGG;WACW,eAAe,CAAC,GAAG,MAAM,EAAE,aAAa,EAAE,GAAG,aAAa,EAAE;CAS1E"}
|
||||
+300
@@ -0,0 +1,300 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Embed = void 0;
|
||||
const tslib_1 = require("tslib");
|
||||
const ow_1 = tslib_1.__importDefault(require("ow"));
|
||||
const Assertions_1 = require("./Assertions");
|
||||
/**
|
||||
* Represents an embed in a message (image/video preview, rich embed, etc.)
|
||||
*/
|
||||
class Embed {
|
||||
constructor(data = {}) {
|
||||
/**
|
||||
* An array of fields of this embed.
|
||||
*/
|
||||
Object.defineProperty(this, "fields", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed title.
|
||||
*/
|
||||
Object.defineProperty(this, "title", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed description.
|
||||
*/
|
||||
Object.defineProperty(this, "description", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed url.
|
||||
*/
|
||||
Object.defineProperty(this, "url", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed color.
|
||||
*/
|
||||
Object.defineProperty(this, "color", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The timestamp of the embed in the ISO format.
|
||||
*/
|
||||
Object.defineProperty(this, "timestamp", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed thumbnail data.
|
||||
*/
|
||||
Object.defineProperty(this, "thumbnail", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed image data.
|
||||
*/
|
||||
Object.defineProperty(this, "image", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* Received video data.
|
||||
*/
|
||||
Object.defineProperty(this, "video", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed author data.
|
||||
*/
|
||||
Object.defineProperty(this, "author", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* Received data about the embed provider.
|
||||
*/
|
||||
Object.defineProperty(this, "provider", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
/**
|
||||
* The embed footer data.
|
||||
*/
|
||||
Object.defineProperty(this, "footer", {
|
||||
enumerable: true,
|
||||
configurable: true,
|
||||
writable: true,
|
||||
value: void 0
|
||||
});
|
||||
this.title = data.title;
|
||||
this.description = data.description;
|
||||
this.url = data.url;
|
||||
this.color = data.color;
|
||||
this.thumbnail = data.thumbnail;
|
||||
this.image = data.image;
|
||||
this.video = data.video;
|
||||
this.author = data.author;
|
||||
this.provider = data.provider;
|
||||
this.footer = data.footer;
|
||||
this.fields = data.fields ?? [];
|
||||
if (data.timestamp)
|
||||
this.timestamp = new Date(data.timestamp).toISOString();
|
||||
}
|
||||
/**
|
||||
* The accumulated length for the embed title, description, fields, footer text, and author name.
|
||||
*/
|
||||
get length() {
|
||||
return ((this.title?.length ?? 0) +
|
||||
(this.description?.length ?? 0) +
|
||||
this.fields.reduce((prev, curr) => prev + curr.name.length + curr.value.length, 0) +
|
||||
(this.footer?.text.length ?? 0) +
|
||||
(this.author?.name?.length ?? 0));
|
||||
}
|
||||
/**
|
||||
* Adds a field to the embed (max 25).
|
||||
* @param field The field to add.
|
||||
*/
|
||||
addField(field) {
|
||||
return this.addFields(field);
|
||||
}
|
||||
/**
|
||||
* Adds fields to the embed (max 25).
|
||||
* @param fields The fields to add.
|
||||
*/
|
||||
addFields(...fields) {
|
||||
// Data assertions
|
||||
ow_1.default(fields, 'fields', Assertions_1.embedFieldsArrayPredicate);
|
||||
// Ensure adding these fields won't exceed the 25 field limit
|
||||
Assertions_1.validateFieldLength(this.fields, fields.length);
|
||||
this.fields.push(...Embed.normalizeFields(...fields));
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
spliceFields(index, deleteCount, ...fields) {
|
||||
// Data assertions
|
||||
ow_1.default(fields, 'fields', Assertions_1.embedFieldsArrayPredicate);
|
||||
// Ensure adding these fields won't exceed the 25 field limit
|
||||
Assertions_1.validateFieldLength(this.fields, fields.length - deleteCount);
|
||||
this.fields.splice(index, deleteCount, ...Embed.normalizeFields(...fields));
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the author of this embed.
|
||||
* @param options The options for the author.
|
||||
*/
|
||||
setAuthor(options) {
|
||||
if (options === null) {
|
||||
this.author = undefined;
|
||||
return this;
|
||||
}
|
||||
const { name, iconURL, url } = options;
|
||||
// Data assertions
|
||||
ow_1.default(name, 'name', Assertions_1.authorNamePredicate);
|
||||
ow_1.default(iconURL, 'iconURL', Assertions_1.urlPredicate);
|
||||
ow_1.default(url, 'url', Assertions_1.urlPredicate);
|
||||
this.author = { name, url, icon_url: iconURL };
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the color of this embed.
|
||||
* @param color The color of the embed.
|
||||
*/
|
||||
setColor(color) {
|
||||
// Data assertions
|
||||
ow_1.default(color, 'color', Assertions_1.colorPredicate);
|
||||
this.color = color ?? undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the description of this embed.
|
||||
* @param description The description.
|
||||
*/
|
||||
setDescription(description) {
|
||||
// Data assertions
|
||||
ow_1.default(description, 'description', Assertions_1.descriptionPredicate);
|
||||
this.description = description ?? undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the footer of this embed.
|
||||
* @param options The options for the footer.
|
||||
*/
|
||||
setFooter(options) {
|
||||
if (options === null) {
|
||||
this.footer = undefined;
|
||||
return this;
|
||||
}
|
||||
const { text, iconURL } = options;
|
||||
// Data assertions
|
||||
ow_1.default(text, 'text', Assertions_1.footerTextPredicate);
|
||||
ow_1.default(iconURL, 'iconURL', Assertions_1.urlPredicate);
|
||||
this.footer = { text, icon_url: iconURL };
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the image of this embed.
|
||||
* @param url The URL of the image.
|
||||
*/
|
||||
setImage(url) {
|
||||
// Data assertions
|
||||
ow_1.default(url, 'url', Assertions_1.urlPredicate);
|
||||
this.image = url ? { url } : undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the thumbnail of this embed.
|
||||
* @param url The URL of the thumbnail.
|
||||
*/
|
||||
setThumbnail(url) {
|
||||
// Data assertions
|
||||
ow_1.default(url, 'url', Assertions_1.urlPredicate);
|
||||
this.thumbnail = url ? { url } : undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the timestamp of this embed.
|
||||
* @param timestamp The timestamp or date.
|
||||
*/
|
||||
setTimestamp(timestamp = Date.now()) {
|
||||
// Data assertions
|
||||
ow_1.default(timestamp, 'timestamp', Assertions_1.timestampPredicate);
|
||||
this.timestamp = timestamp ? new Date(timestamp).toISOString() : undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the title of this embed.
|
||||
* @param title The title.
|
||||
*/
|
||||
setTitle(title) {
|
||||
// Data assertions
|
||||
ow_1.default(title, 'title', Assertions_1.titlePredicate);
|
||||
this.title = title ?? undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Sets the URL of this embed.
|
||||
* @param url The URL.
|
||||
*/
|
||||
setURL(url) {
|
||||
// Data assertions
|
||||
ow_1.default(url, 'url', Assertions_1.urlPredicate);
|
||||
this.url = url ?? undefined;
|
||||
return this;
|
||||
}
|
||||
/**
|
||||
* Transforms the embed to a plain object.
|
||||
*/
|
||||
toJSON() {
|
||||
return { ...this };
|
||||
}
|
||||
/**
|
||||
* Normalizes field input and resolves strings.
|
||||
* @param fields Fields to normalize.
|
||||
*/
|
||||
static normalizeFields(...fields) {
|
||||
return fields.flat(Infinity).map((field) => {
|
||||
ow_1.default(field.name, 'field name', Assertions_1.fieldNamePredicate);
|
||||
ow_1.default(field.value, 'field value', Assertions_1.fieldValuePredicate);
|
||||
ow_1.default(field.inline, 'field inline', Assertions_1.fieldInlinePredicate);
|
||||
return { name: field.name, value: field.value, inline: field.inline ?? undefined };
|
||||
});
|
||||
}
|
||||
}
|
||||
exports.Embed = Embed;
|
||||
//# sourceMappingURL=Embed.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
+198
@@ -0,0 +1,198 @@
|
||||
/// <reference types="node" />
|
||||
import type { Snowflake } from 'discord-api-types/globals';
|
||||
import type { URL } from 'url';
|
||||
/**
|
||||
* Wraps the content inside a codeblock with no language.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare function codeBlock<L extends string, C extends string>(language: L, content: C): `\`\`\`${L}\n${C}\`\`\``;
|
||||
/**
|
||||
* Wraps the content inside \`backticks\`, which formats it as inline code.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare function inlineCode<C extends string>(content: C): `\`${C}\``;
|
||||
/**
|
||||
* Formats the content into italic text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare function italic<C extends string>(content: C): `_${C}_`;
|
||||
/**
|
||||
* Formats the content into bold text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare function bold<C extends string>(content: C): `**${C}**`;
|
||||
/**
|
||||
* Formats the content into underscored text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare function underscore<C extends string>(content: C): `__${C}__`;
|
||||
/**
|
||||
* Formats the content into strike-through text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare function blockQuote<C extends string>(content: C): `>>> ${C}`;
|
||||
/**
|
||||
* Wraps the URL into `<>`, which stops it from embedding.
|
||||
* @param url The URL to wrap.
|
||||
*/
|
||||
export declare function hideLinkEmbed<C extends string>(url: C): `<${C}>`;
|
||||
/**
|
||||
* Wraps the URL into `<>`, which stops it from embedding.
|
||||
* @param url The URL to wrap.
|
||||
*/
|
||||
export declare function hideLinkEmbed(url: URL): `<${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.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare function hyperlink<C extends string, T extends string>(content: C, url: URL, title: T): `[${C}](${string} "${T}")`;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
export declare function hyperlink<C extends string, U extends string, T extends string>(content: C, url: U, title: T): `[${C}](${U} "${T}")`;
|
||||
/**
|
||||
* Wraps the content inside spoiler (hidden text).
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
export declare function spoiler<C extends string>(content: C): `||${C}||`;
|
||||
/**
|
||||
* Formats a user ID into a user mention.
|
||||
* @param userId The user ID to format.
|
||||
*/
|
||||
export declare function userMention<C extends Snowflake>(userId: C): `<@${C}>`;
|
||||
/**
|
||||
* Formats a user ID into a member-nickname mention.
|
||||
* @param memberId The user ID to format.
|
||||
*/
|
||||
export declare function memberNicknameMention<C extends Snowflake>(memberId: C): `<@!${C}>`;
|
||||
/**
|
||||
* Formats a channel ID into a channel mention.
|
||||
* @param channelId The channel ID to format.
|
||||
*/
|
||||
export declare function channelMention<C extends Snowflake>(channelId: C): `<#${C}>`;
|
||||
/**
|
||||
* Formats a role ID into a role mention.
|
||||
* @param roleId The role ID to format.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare 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`
|
||||
*/
|
||||
export declare function formatEmoji<C extends Snowflake>(emojiId: C, animated?: true): `<a:_:${C}>`;
|
||||
/**
|
||||
* Formats a date into a short date-time string.
|
||||
* @param date The date to format, defaults to the current time.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare 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.
|
||||
*/
|
||||
export declare function time<C extends number, S extends TimestampStylesString>(seconds: C, style: S): `<t:${C}:${S}>`;
|
||||
/**
|
||||
* The [message formatting timestamp styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord.
|
||||
*/
|
||||
export declare const TimestampStyles: {
|
||||
/**
|
||||
* Short time format, consisting of hours and minutes, e.g. 16:20.
|
||||
*/
|
||||
readonly ShortTime: "t";
|
||||
/**
|
||||
* Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30.
|
||||
*/
|
||||
readonly LongTime: "T";
|
||||
/**
|
||||
* Short date format, consisting of day, month, and year, e.g. 20/04/2021.
|
||||
*/
|
||||
readonly ShortDate: "d";
|
||||
/**
|
||||
* Long date format, consisting of day, month, and year, e.g. 20 April 2021.
|
||||
*/
|
||||
readonly LongDate: "D";
|
||||
/**
|
||||
* Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20.
|
||||
*/
|
||||
readonly ShortDateTime: "f";
|
||||
/**
|
||||
* Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20.
|
||||
*/
|
||||
readonly LongDateTime: "F";
|
||||
/**
|
||||
* Relative time format, consisting of a relative duration format, e.g. 2 months ago.
|
||||
*/
|
||||
readonly RelativeTime: "R";
|
||||
};
|
||||
/**
|
||||
* The possible values, see {@link TimestampStyles} for more information.
|
||||
*/
|
||||
export declare type TimestampStylesString = typeof TimestampStyles[keyof typeof TimestampStyles];
|
||||
/**
|
||||
* An enum with all the available faces from Discord's native slash commands
|
||||
*/
|
||||
export declare enum Faces {
|
||||
/**
|
||||
* ¯\\_(ツ)\\_/¯
|
||||
*/
|
||||
Shrug = "\u00AF\\_(\u30C4)\\_/\u00AF",
|
||||
/**
|
||||
* (╯°□°)╯︵ ┻━┻
|
||||
*/
|
||||
Tableflip = "(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35 \u253B\u2501\u253B",
|
||||
/**
|
||||
* ┬─┬ ノ( ゜-゜ノ)
|
||||
*/
|
||||
Unflip = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)"
|
||||
}
|
||||
//# sourceMappingURL=formatters.d.ts.map
|
||||
+1
@@ -0,0 +1 @@
|
||||
{"version":3,"file":"formatters.d.ts","sourceRoot":"/","sources":["messages/formatters.ts"],"names":[],"mappings":";AAAA,OAAO,KAAK,EAAE,SAAS,EAAE,MAAM,2BAA2B,CAAC;AAC3D,OAAO,KAAK,EAAE,GAAG,EAAE,MAAM,KAAK,CAAC;AAE/B;;;GAGG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,WAAW,CAAC,QAAQ,CAAC;AAE9E;;;;GAIG;AACH,wBAAgB,SAAS,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,MAAM,EAAE,QAAQ,EAAE,CAAC,EAAE,OAAO,EAAE,CAAC,GAAG,SAAS,CAAC,KAAK,CAAC,QAAQ,CAAC;AAKjH;;;GAGG;AACH,wBAAgB,UAAU,CAAC,CA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S,SAAS,EAAE,OAAO,EAAE,CAAC,EAAE,QAAQ,CAAC,EAAE,IAAI,GAAG,QAAQ,CAAC,GAAG,CAAC;AAW5F;;;GAGG;AACH,wBAAgB,IAAI,CAAC,IAAI,CAAC,EAAE,IAAI,GAAG,MAAM,MAAM,GAAG,CAAC;AAEnD;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,qBAAqB,EAAE,IAAI,EAAE,IAAI,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,MAAM,IAAI,CAAC,GAAG,CAAC;AAElG;;;GAGG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,OAAO,EAAE,CAAC,GAAG,MAAM,CAAC,GAAG,CAAC;AAE/D;;;;GAIG;AACH,wBAAgB,IAAI,CAAC,CAAC,SAAS,MAAM,EAAE,CAAC,SAAS,qBAAqB,EAAE,OAAO,EAAE,CAAC,EAAE,KAAK,EAAE,CAAC,GAAG,MAAM,CAAC,IAAI,CAAC,GAAG,CAAC;AAS/G;;GAEG;AACH,eAAO,MAAM,eAAe;IAC3B;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;IAGH;;OAEG;;CAEM,CAAC;AAEX;;GAEG;AACH,oBAAY,qBAAqB,GAAG,OAAO,eAAe,CAAC,MAAM,OAAO,eAAe,CAAC,CAAC;AAEzF;;GAEG;AACH,oBAAY,KAAK;IAChB;;OAEG;IACH,KAAK,gCAAiB;IAEtB;;OAEG;IACH,SAAS,mEAAiB;IAE1B;;OAEG;IACH,MAAM,oDAAiB;CACvB"}
|
||||
+181
@@ -0,0 +1,181 @@
|
||||
"use strict";
|
||||
Object.defineProperty(exports, "__esModule", { value: true });
|
||||
exports.Faces = exports.TimestampStyles = exports.time = exports.formatEmoji = exports.roleMention = exports.channelMention = exports.memberNicknameMention = exports.userMention = exports.spoiler = exports.hyperlink = exports.hideLinkEmbed = exports.blockQuote = exports.quote = exports.strikethrough = exports.underscore = exports.bold = exports.italic = exports.inlineCode = exports.codeBlock = void 0;
|
||||
function codeBlock(language, content) {
|
||||
return typeof content === 'undefined' ? `\`\`\`\n${language}\`\`\`` : `\`\`\`${language}\n${content}\`\`\``;
|
||||
}
|
||||
exports.codeBlock = codeBlock;
|
||||
/**
|
||||
* Wraps the content inside \`backticks\`, which formats it as inline code.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
function inlineCode(content) {
|
||||
return `\`${content}\``;
|
||||
}
|
||||
exports.inlineCode = inlineCode;
|
||||
/**
|
||||
* Formats the content into italic text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
function italic(content) {
|
||||
return `_${content}_`;
|
||||
}
|
||||
exports.italic = italic;
|
||||
/**
|
||||
* Formats the content into bold text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
function bold(content) {
|
||||
return `**${content}**`;
|
||||
}
|
||||
exports.bold = bold;
|
||||
/**
|
||||
* Formats the content into underscored text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
function underscore(content) {
|
||||
return `__${content}__`;
|
||||
}
|
||||
exports.underscore = underscore;
|
||||
/**
|
||||
* Formats the content into strike-through text.
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
function strikethrough(content) {
|
||||
return `~~${content}~~`;
|
||||
}
|
||||
exports.strikethrough = strikethrough;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function quote(content) {
|
||||
return `> ${content}`;
|
||||
}
|
||||
exports.quote = quote;
|
||||
/**
|
||||
* 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.
|
||||
*/
|
||||
function blockQuote(content) {
|
||||
return `>>> ${content}`;
|
||||
}
|
||||
exports.blockQuote = blockQuote;
|
||||
function hideLinkEmbed(url) {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
return `<${url}>`;
|
||||
}
|
||||
exports.hideLinkEmbed = hideLinkEmbed;
|
||||
function hyperlink(content, url, title) {
|
||||
// eslint-disable-next-line @typescript-eslint/restrict-template-expressions
|
||||
return title ? `[${content}](${url} "${title}")` : `[${content}](${url})`;
|
||||
}
|
||||
exports.hyperlink = hyperlink;
|
||||
/**
|
||||
* Wraps the content inside spoiler (hidden text).
|
||||
* @param content The content to wrap.
|
||||
*/
|
||||
function spoiler(content) {
|
||||
return `||${content}||`;
|
||||
}
|
||||
exports.spoiler = spoiler;
|
||||
/**
|
||||
* Formats a user ID into a user mention.
|
||||
* @param userId The user ID to format.
|
||||
*/
|
||||
function userMention(userId) {
|
||||
return `<@${userId}>`;
|
||||
}
|
||||
exports.userMention = userMention;
|
||||
/**
|
||||
* Formats a user ID into a member-nickname mention.
|
||||
* @param memberId The user ID to format.
|
||||
*/
|
||||
function memberNicknameMention(memberId) {
|
||||
return `<@!${memberId}>`;
|
||||
}
|
||||
exports.memberNicknameMention = memberNicknameMention;
|
||||
/**
|
||||
* Formats a channel ID into a channel mention.
|
||||
* @param channelId The channel ID to format.
|
||||
*/
|
||||
function channelMention(channelId) {
|
||||
return `<#${channelId}>`;
|
||||
}
|
||||
exports.channelMention = channelMention;
|
||||
/**
|
||||
* Formats a role ID into a role mention.
|
||||
* @param roleId The role ID to format.
|
||||
*/
|
||||
function roleMention(roleId) {
|
||||
return `<@&${roleId}>`;
|
||||
}
|
||||
exports.roleMention = roleMention;
|
||||
/**
|
||||
* 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`
|
||||
*/
|
||||
function formatEmoji(emojiId, animated = false) {
|
||||
return `<${animated ? 'a' : ''}:_:${emojiId}>`;
|
||||
}
|
||||
exports.formatEmoji = formatEmoji;
|
||||
function time(timeOrSeconds, style) {
|
||||
if (typeof timeOrSeconds !== 'number') {
|
||||
timeOrSeconds = Math.floor((timeOrSeconds?.getTime() ?? Date.now()) / 1000);
|
||||
}
|
||||
return typeof style === 'string' ? `<t:${timeOrSeconds}:${style}>` : `<t:${timeOrSeconds}>`;
|
||||
}
|
||||
exports.time = time;
|
||||
/**
|
||||
* The [message formatting timestamp styles](https://discord.com/developers/docs/reference#message-formatting-timestamp-styles) supported by Discord.
|
||||
*/
|
||||
exports.TimestampStyles = {
|
||||
/**
|
||||
* Short time format, consisting of hours and minutes, e.g. 16:20.
|
||||
*/
|
||||
ShortTime: 't',
|
||||
/**
|
||||
* Long time format, consisting of hours, minutes, and seconds, e.g. 16:20:30.
|
||||
*/
|
||||
LongTime: 'T',
|
||||
/**
|
||||
* Short date format, consisting of day, month, and year, e.g. 20/04/2021.
|
||||
*/
|
||||
ShortDate: 'd',
|
||||
/**
|
||||
* Long date format, consisting of day, month, and year, e.g. 20 April 2021.
|
||||
*/
|
||||
LongDate: 'D',
|
||||
/**
|
||||
* Short date-time format, consisting of short date and short time formats, e.g. 20 April 2021 16:20.
|
||||
*/
|
||||
ShortDateTime: 'f',
|
||||
/**
|
||||
* Long date-time format, consisting of long date and short time formats, e.g. Tuesday, 20 April 2021 16:20.
|
||||
*/
|
||||
LongDateTime: 'F',
|
||||
/**
|
||||
* Relative time format, consisting of a relative duration format, e.g. 2 months ago.
|
||||
*/
|
||||
RelativeTime: 'R',
|
||||
};
|
||||
/**
|
||||
* An enum with all the available faces from Discord's native slash commands
|
||||
*/
|
||||
var Faces;
|
||||
(function (Faces) {
|
||||
/**
|
||||
* ¯\\_(ツ)\\_/¯
|
||||
*/
|
||||
Faces["Shrug"] = "\u00AF\\_(\u30C4)\\_/\u00AF";
|
||||
/**
|
||||
* (╯°□°)╯︵ ┻━┻
|
||||
*/
|
||||
Faces["Tableflip"] = "(\u256F\u00B0\u25A1\u00B0\uFF09\u256F\uFE35 \u253B\u2501\u253B";
|
||||
/**
|
||||
* ┬─┬ ノ( ゜-゜ノ)
|
||||
*/
|
||||
Faces["Unflip"] = "\u252C\u2500\u252C \u30CE( \u309C-\u309C\u30CE)";
|
||||
})(Faces = exports.Faces || (exports.Faces = {}));
|
||||
//# sourceMappingURL=formatters.js.map
|
||||
+1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user