UNPKG

@evolvejs/core

Version:

An advanced Discord API wrapper with TS and JS support

51 lines (50 loc) 2.32 kB
"use strict"; var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { function adopt(value) { return value instanceof P ? value : new P(function (resolve) { resolve(value); }); } return new (P || (P = Promise))(function (resolve, reject) { function fulfilled(value) { try { step(generator.next(value)); } catch (e) { reject(e); } } function rejected(value) { try { step(generator["throw"](value)); } catch (e) { reject(e); } } function step(result) { result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected); } step((generator = generator.apply(thisArg, _arguments || [])).next()); }); }; Object.defineProperty(exports, "__esModule", { value: true }); exports.TextChannel = void 0; const Channel_1 = require("./Channel"); const objex_1 = require("@evolvejs/objex"); const Message_1 = require("../Message/Message"); const Constants_1 = require("../../Utils/Constants"); const Endpoints_1 = require("../../Utils/Endpoints"); class TextChannel extends Channel_1.Channel { constructor(data, client) { super(data.id, Constants_1.CHANNELTYPES.Text, client); this.overwrites = new objex_1.Objex(); Object.defineProperty(this, "data", { value: data, enumerable: false, writable: false, }); this._handle(); } _handle() { var _a, _b; if (!this.data) return; this.guild = this.client.guilds.get(this.data.guild_id); this.position = this.data.position; this.name = this.data.name; this.topic = (_a = this.data.topic) !== null && _a !== void 0 ? _a : ""; this.nsfw = this.data.nsfw; this.rateLimit = this.data.rate_limit_per_user; this.parentId = (_b = this.data.parent_id) !== null && _b !== void 0 ? _b : undefined; this.lastPin = this.data.last_pin_timestamp; } send(content) { return __awaiter(this, void 0, void 0, function* () { return new Message_1.Message(yield this.client.rest .endpoint(Endpoints_1.Endpoints.CHANNEL_MESSAGES) .post(typeof content === "string" ? { content } : { embed: content }, this.id), this.client); }); } } exports.TextChannel = TextChannel;