UNPKG

seyfert

Version:

The most advanced framework for discord bots

88 lines (87 loc) 4.41 kB
"use strict"; var __createBinding = (this && this.__createBinding) || (Object.create ? (function(o, m, k, k2) { if (k2 === undefined) k2 = k; var desc = Object.getOwnPropertyDescriptor(m, k); if (!desc || ("get" in desc ? !m.__esModule : desc.writable || desc.configurable)) { desc = { enumerable: true, get: function() { return m[k]; } }; } Object.defineProperty(o, k2, desc); }) : (function(o, m, k, k2) { if (k2 === undefined) k2 = k; o[k2] = m[k]; })); var __exportStar = (this && this.__exportStar) || function(m, exports) { for (var p in m) if (p !== "default" && !Object.prototype.hasOwnProperty.call(exports, p)) __createBinding(exports, m, p); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.componentFactory = componentFactory; const types_1 = require("../types"); const ActionRow_1 = require("./ActionRow"); const BaseComponent_1 = require("./BaseComponent"); const ButtonComponent_1 = require("./ButtonComponent"); const ChannelSelectMenuComponent_1 = require("./ChannelSelectMenuComponent"); const Container_1 = require("./Container"); const File_1 = require("./File"); const MediaGallery_1 = require("./MediaGallery"); const MentionableSelectMenuComponent_1 = require("./MentionableSelectMenuComponent"); const RoleSelectMenuComponent_1 = require("./RoleSelectMenuComponent"); const Section_1 = require("./Section"); const Separator_1 = require("./Separator"); const StringSelectMenuComponent_1 = require("./StringSelectMenuComponent"); const TextDisplay_1 = require("./TextDisplay"); const TextInputComponent_1 = require("./TextInputComponent"); const Thumbnail_1 = require("./Thumbnail"); const UserSelectMenuComponent_1 = require("./UserSelectMenuComponent"); __exportStar(require("./componentcommand"), exports); __exportStar(require("./componentcontext"), exports); __exportStar(require("./modalcommand"), exports); __exportStar(require("./modalcontext"), exports); /** * Return a new component instance based on the component type. * * @param component The component to create. * @returns The component instance. */ function componentFactory(component) { switch (component.type) { case types_1.ComponentType.Button: { if (component.style === types_1.ButtonStyle.Link) { return new ButtonComponent_1.LinkButtonComponent(component); } if (component.style === types_1.ButtonStyle.Premium) { return new ButtonComponent_1.SKUButtonComponent(component); } return new ButtonComponent_1.ButtonComponent(component); } case types_1.ComponentType.ChannelSelect: return new ChannelSelectMenuComponent_1.ChannelSelectMenuComponent(component); case types_1.ComponentType.RoleSelect: return new RoleSelectMenuComponent_1.RoleSelectMenuComponent(component); case types_1.ComponentType.StringSelect: return new StringSelectMenuComponent_1.StringSelectMenuComponent(component); case types_1.ComponentType.UserSelect: return new UserSelectMenuComponent_1.UserSelectMenuComponent(component); case types_1.ComponentType.MentionableSelect: return new MentionableSelectMenuComponent_1.MentionableSelectMenuComponent(component); case types_1.ComponentType.ActionRow: return new ActionRow_1.MessageActionRowComponent(component); case types_1.ComponentType.Container: return new Container_1.ContainerComponent(component); case types_1.ComponentType.File: return new File_1.FileComponent(component); case types_1.ComponentType.MediaGallery: return new MediaGallery_1.MediaGalleryComponent(component); case types_1.ComponentType.Section: return new Section_1.SectionComponent(component); case types_1.ComponentType.TextDisplay: return new TextDisplay_1.TextDisplayComponent(component); case types_1.ComponentType.Separator: return new Separator_1.SeparatorComponent(component); case types_1.ComponentType.Thumbnail: return new Thumbnail_1.ThumbnailComponent(component); case types_1.ComponentType.TextInput: return new TextInputComponent_1.TextInputComponent(component); default: return new BaseComponent_1.BaseComponent(component); } }