guilded.ts
Version:
A powerful NPM module that allows you to easily interact with the Guilded API.
76 lines • 2.73 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.ListItemNote = void 0;
const Base_1 = require("../Base");
/**
* Represents a list item note on Guilded.
* @example new ListItemNote(item, rawListItemNote);
*/
class ListItemNote extends Base_1.Base {
item;
raw;
/** The date the list item note was created. */
createdAt;
/** The ID of the user that created the list item note. */
createdBy;
/** The date the list item note was edited. */
editedAt;
/** The ID of the user that edited the list item note. */
editedBy;
/** The mentions of the list item note. */
mentions;
/** The content of the list item note. */
content;
/**
* @param item The list item the note belongs to.
* @param raw The raw data of the list item note.
*/
constructor(item, raw) {
super(item.client, item.id);
this.item = item;
this.raw = raw;
this.content = 'content' in raw ? raw.content : undefined;
this.createdAt = new Date(raw.createdAt);
this.createdBy = raw.createdBy;
this.editedAt = raw.updatedAt ? new Date(raw.updatedAt) : undefined;
this.editedBy = raw.updatedBy;
}
/** The timestamp the list item note was created. */
get createdTimestamp() {
return this.createdAt.getTime();
}
/** The server member that created the list item note. */
get author() {
return this.item.server?.members.cache.get(this.createdBy);
}
/** The timestamp the list item note was edited. */
get editedTimestamp() {
return this.editedAt ? this.editedAt.getTime() : undefined;
}
/** The server member that edited the list item note. */
get editor() {
return this.editedBy ? this.item.server?.members.cache.get(this.editedBy) : undefined;
}
/**
* Fetch the server member that created the list item note.
* @param options The options to fetch the server member with.
* @returns The fetched server member.
* @example note.fetchAuthor();
*/
async fetchAuthor(options) {
const server = await this.item.fetchServer();
return server.members.fetch(this.createdBy, options);
}
/**
* Fetch the server member that edited the list item note.
* @param options The options to fetch the server member with.
* @returns The fetched server member.
* @example note.fetchEditor();
*/
async fetchEditor(options) {
const server = await this.item.fetchServer();
return this.editedBy ? server.members.fetch(this.editedBy, options) : undefined;
}
}
exports.ListItemNote = ListItemNote;
//# sourceMappingURL=ListItemNote.js.map