guilded.ts
Version:
A powerful NPM module that allows you to easily interact with the Guilded API.
155 lines • 5.8 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.CalendarEventRsvpStatus = exports.CalendarEventRsvp = void 0;
const guilded_api_typings_1 = require("guilded-api-typings");
Object.defineProperty(exports, "CalendarEventRsvpStatus", { enumerable: true, get: function () { return guilded_api_typings_1.CalendarEventRsvpStatus; } });
const Base_1 = require("../Base");
/**
* Represents a calendar event RSVP on Guilded.
* @example new CalendarEventRsvp(calendarEvent, rawCalendarEventRsvp);
*/
class CalendarEventRsvp extends Base_1.Base {
calendarEvent;
raw;
/** The ID of the calendar event the RSVP belongs to. */
calendarEventId;
/** The ID of the channel the calendar event RSVP belongs to. */
channelId;
/** The ID of the server the calendar event RSVP belongs to. */
serverId;
/** The ID of the user the calendar event RSVP belongs to. */
userId;
/** The status of the calendar event RSVP. */
status;
/** The ID of the user that created the calendar event RSVP. */
createdBy;
/** The date the calendar event RSVP was created. */
createdAt;
/** The ID of the user that edited the calendar event RSVP. */
editedBy;
/** The date the calendar event RSVP was edited. */
editedAt;
/**
* @param calendarEvent The calendar event the RSVP belongs to.
* @param raw The raw data of the calendar event RSVP.
* @param cache Whether to cache the calendar event RSVP.
*/
constructor(calendarEvent, raw, cache = calendarEvent.client.options.cacheCalendarEventRsvps ?? true) {
super(calendarEvent.client, raw.userId);
this.calendarEvent = calendarEvent;
this.raw = raw;
this.calendarEventId = raw.calendarEventId;
this.channelId = raw.channelId;
this.serverId = raw.serverId;
this.userId = raw.userId;
this.status = raw.status;
this.createdBy = raw.createdBy;
this.createdAt = new Date(raw.createdAt);
this.editedBy = raw.updatedBy;
this.editedAt = raw.updatedAt ? new Date(raw.updatedAt) : undefined;
if (cache)
calendarEvent.rsvps.cache.set(this.id, this);
}
/** Whether the calendar event RSVP is cached. */
get isCached() {
return this.calendarEvent.rsvps.cache.has(this.id);
}
/** The channel the calendar event RSVP belongs to. */
get channel() {
return this.calendarEvent.channel;
}
/** The server the calendar event RSVP belongs to. */
get server() {
return this.calendarEvent.server;
}
/** The user the calendar event RSVP belongs to. */
get user() {
return this.client.users.cache.get(this.userId);
}
/** The server member that created the calendar event RSVP. */
get author() {
return this.server?.members.cache.get(this.createdBy);
}
/** The ID of the user that created the calendar event RSVP. */
get authorId() {
return this.createdBy;
}
/** The timestamp the calendar event RSVP was created. */
get createdTimestamp() {
return this.createdAt.getTime();
}
/** The server member that edited the calendar event RSVP. */
get editor() {
return this.editedBy ? this.server?.members.cache.get(this.editedBy) : undefined;
}
/** The timestamp the calendar event RSVP was edited. */
get editedTimestamp() {
return this.editedAt?.getTime();
}
/**
* Fetch the calendar event RSVP.
* @param options The options to fetch the calendar event RSVP with.
* @returns The fetched calendar event RSVP.
* @example calendarEventRsvp.fetch();
*/
fetch(options) {
return this.calendarEvent.rsvps.fetch(this.id, options);
}
/**
* Fetch the server the calendar event RSVP belongs to.
* @param options The options to fetch the server with.
* @returns The fetched server.
* @example calendarEventRsvp.fetchServer();
*/
fetchServer(options) {
return this.calendarEvent.fetchServer(options);
}
/**
* Fetch the user the calendar event RSVP belongs to.
* @returns The fetched user.
* @example calendarEventRsvp.fetchUser();
*/
fetchUser() {
return this.client.users.fetch(this.serverId, this.userId);
}
/**
* Fetch the server member that created the calendar event RSVP.
* @param options The options to fetch the server member with.
* @returns The fetched server member.
* @example calendarEventRsvp.fetchAuthor();
*/
async fetchAuthor(options) {
const server = await this.fetchServer();
return server.members.fetch(this.createdBy, options);
}
/**
* Fetch the server member that edited the calendar event RSVP.
* @param options The options to fetch the server member with.
* @returns The fetched server member.
* @example calendarEventRsvp.fetchEditor();
*/
async fetchEditor(options) {
const server = await this.fetchServer();
return this.editedBy ? server.members.fetch(this.editedBy, options) : undefined;
}
/**
* Edit the calendar event RSVP.
* @param status The status of the calendar event RSVP.
* @returns The edited calendar event RSVP.
* @example calendarEventRsvp.edit('going');
*/
edit(status) {
return this.calendarEvent.rsvps.edit(this, status);
}
/**
* Delete the calendar event RSVP.
* @returns The deleted calendar event RSVP.
* @example calendarEventRsvp.delete();
*/
async delete() {
await this.calendarEvent.rsvps.delete(this);
return this;
}
}
exports.CalendarEventRsvp = CalendarEventRsvp;
//# sourceMappingURL=CalendarEventRsvp.js.map