UNPKG

guilded.ts

Version:

A powerful NPM module that allows you to easily interact with the Guilded API.

74 lines 3.53 kB
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.CalendarEventRsvpManager = void 0; const collection_1 = require("@discordjs/collection"); const CalendarEventRsvp_1 = require("../../structures/calendarEvent/CalendarEventRsvp"); const BaseManager_1 = require("../BaseManager"); /** * The manager of RSVPs that belong to a calendar event. * @example new CalendarEventRsvpManager(calendarEvent); */ class CalendarEventRsvpManager extends BaseManager_1.BaseManager { calendarEvent; /** @param calendarEvent The calendar event the RSVPs belong to. */ constructor(calendarEvent) { super(calendarEvent.client, calendarEvent.client.options.maxCalendarEventRsvpCache); this.calendarEvent = calendarEvent; } fetch(arg1, arg2) { if (typeof arg1 === 'string' || arg1 instanceof CalendarEventRsvp_1.CalendarEventRsvp) return this.fetchSingle(arg1, arg2); return this.fetchMany(arg1); } /** @ignore */ async fetchSingle(calendarEventRsvp, options) { calendarEventRsvp = calendarEventRsvp instanceof CalendarEventRsvp_1.CalendarEventRsvp ? calendarEventRsvp.id : calendarEventRsvp; const cached = this.cache.get(calendarEventRsvp); if (cached && !options?.force) return cached; const raw = await this.client.api.calendarEventRsvps.fetch(this.calendarEvent.channelId, this.calendarEvent.id, calendarEventRsvp); return new CalendarEventRsvp_1.CalendarEventRsvp(this.calendarEvent, raw, options?.cache); } /** @ignore */ async fetchMany(options) { const raw = await this.client.api.calendarEventRsvps.fetch(this.calendarEvent.channelId, this.calendarEvent.id); const calendarEventRsvps = new collection_1.Collection(); for (const data of raw) { const calendarEventRsvp = new CalendarEventRsvp_1.CalendarEventRsvp(this.calendarEvent, data, options?.cache); calendarEventRsvps.set(calendarEventRsvp.id, calendarEventRsvp); } return calendarEventRsvps; } /** * Edit a RSVP in the calendar event. * @param calendarEventRsvp The calendar event RSVP to edit. * @param status The status of the RSVP. * @returns The edited calendar event RSVP. * @example calanderEventRsvps.edit(calendarEventRsvp, 'going'); */ async edit(calendarEventRsvp, status) { calendarEventRsvp = calendarEventRsvp instanceof CalendarEventRsvp_1.CalendarEventRsvp ? calendarEventRsvp.id : calendarEventRsvp; const raw = await this.client.api.calendarEventRsvps.edit(this.calendarEvent.channelId, this.calendarEvent.id, calendarEventRsvp, status); return new CalendarEventRsvp_1.CalendarEventRsvp(this.calendarEvent, raw); } /** * Delete a RSVP from the calendar event. * @param calendarEventRsvp The calendar event RSVP to delete. * @example calanderEventRsvps.delete(calendarEventRsvp); */ delete(calendarEventRsvp) { calendarEventRsvp = calendarEventRsvp instanceof CalendarEventRsvp_1.CalendarEventRsvp ? calendarEventRsvp.id : calendarEventRsvp; return this.client.api.calendarEventRsvps.delete(this.calendarEvent.channelId, this.calendarEvent.id, calendarEventRsvp); } } exports.CalendarEventRsvpManager = CalendarEventRsvpManager; //# sourceMappingURL=CalendarEventRsvpManager.js.map