UNPKG

@globalart/nestcord

Version:

A module for creating Discord bots using NestJS, based on Discord.js

55 lines (54 loc) 2.8 kB
"use strict"; var __decorate = (this && this.__decorate) || function (decorators, target, key, desc) { var c = arguments.length, r = c < 3 ? target : desc === null ? desc = Object.getOwnPropertyDescriptor(target, key) : desc, d; if (typeof Reflect === "object" && typeof Reflect.decorate === "function") r = Reflect.decorate(decorators, target, key, desc); else for (var i = decorators.length - 1; i >= 0; i--) if (d = decorators[i]) r = (c < 3 ? d(r) : c > 3 ? d(target, key, r) : d(target, key)) || r; return c > 3 && r && Object.defineProperty(target, key, r), r; }; var __metadata = (this && this.__metadata) || function (k, v) { if (typeof Reflect === "object" && typeof Reflect.metadata === "function") return Reflect.metadata(k, v); }; var __param = (this && this.__param) || function (paramIndex, decorator) { return function (target, key) { decorator(target, key, paramIndex); } }; Object.defineProperty(exports, "__esModule", { value: true }); exports.NestCordPaginationService = void 0; const common_1 = require("@nestjs/common"); const nestcord_pagination_module_definition_1 = require("./nestcord-pagination.module-definition"); const enums_1 = require("./enums"); const buttons_padgination_builder_1 = require("./builders/buttons-padgination.builder"); const select_menu_pagination_builder_1 = require("./builders/select-menu-pagination.builder"); let NestCordPaginationService = class NestCordPaginationService { constructor(options) { this.options = options; this.cache = new Map(); } register(paginatorType, factory) { switch (paginatorType) { case enums_1.PaginatorTypeEnum.BUTTONS: { const builder = factory(new buttons_padgination_builder_1.ButtonsPaginationBuilder(this.options)); this.cache.set(builder.customId, builder); return builder; } case enums_1.PaginatorTypeEnum.SELECT_MENU: { const builder = factory(new select_menu_pagination_builder_1.SelectMenuPaginationBuilder(this.options)); this.cache.set(builder.customId, builder); return builder; } default: throw new Error(`Unsupported paginator type: ${paginatorType}`); } } get(customId) { return this.cache.get(customId); } delete(customId) { return this.cache.delete(customId); } }; exports.NestCordPaginationService = NestCordPaginationService; exports.NestCordPaginationService = NestCordPaginationService = __decorate([ (0, common_1.Injectable)(), __param(0, (0, common_1.Inject)(nestcord_pagination_module_definition_1.NESTCORD_PAGINATION_MODULE_OPTIONS)), __metadata("design:paramtypes", [Object]) ], NestCordPaginationService);