@evolvejs/core
Version:
An advanced Discord API wrapper with TS and JS support
79 lines (78 loc) • 3.98 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.Guild = void 0;
/* eslint-disable no-mixed-spaces-and-tabs */
/* eslint-disable @typescript-eslint/no-non-null-assertion */
const __1 = require("../..");
const objex_1 = require("@evolvejs/objex");
const ChannelsManger_1 = require("../../Client/Managers/ChannelsManger");
class Guild {
constructor(data, client) {
this.members = new objex_1.Objex();
this.roles = new objex_1.Objex();
this.emojis = new objex_1.Objex();
this.voiceStates = new objex_1.Objex();
this.presences = new objex_1.Objex();
this.features = [];
Object.defineProperty(this, "client", {
value: client,
enumerable: false,
writable: false,
});
Object.defineProperty(this, "data", {
value: data,
enumerable: false,
writable: false,
});
this.id = data.id;
this.channels = new ChannelsManger_1.ChannelsManager(client, this);
this._handle();
}
_handle() {
var _a, _b, _c, _d, _e, _f, _g, _h, _j, _k, _l, _m, _o, _p;
if (!this.data)
return;
this.data.emojis.forEach((o) => {
this.emojis.set(o.id, new __1.Emoji(o));
});
this.data.roles.forEach((o) => {
this.roles.set(o.id, new __1.Role(o));
});
this.name = this.data.name;
this.icon = this.data.icon;
this.splash = this.data.splash || undefined;
this.discoverySplash = this.data.discovery_splash || undefined;
this.isOwner = this.data.owner;
this.ownerId = this.data.owner_id;
this.permissions = this.data.permissions;
this.region = this.data.region;
this.afkChannelId = (_a = this.data.afk_channel_id) !== null && _a !== void 0 ? _a : undefined;
this.afkTimeout = this.data.afk_timeout;
this.verificationLevel = this.data.verification_level;
this.defMessageNotify = this.data.default_message_notifications;
this.explicitContentFilter = this.data.explicit_content_filter;
this.mfaLevel = this.data.mfa_level;
this.applicationID = this.data.application_id || undefined;
this.widgetEnabled = (_b = this.data.widget_enabled) !== null && _b !== void 0 ? _b : false;
this.widgetChannelId = (_c = this.data.widget_channel_id) !== null && _c !== void 0 ? _c : undefined;
this.systemChannelId = (_d = this.data.system_channel_id) !== null && _d !== void 0 ? _d : undefined;
this.systemChannelFlag = this.data.system_channel_flags;
this.rulesChannelId = (_e = this.data.rules_channel_id) !== null && _e !== void 0 ? _e : undefined;
this.joinedAt = (_f = this.data.joined_at) !== null && _f !== void 0 ? _f : undefined;
this.large = (_g = this.data.large) !== null && _g !== void 0 ? _g : false;
this.unavailable = (_h = this.data.unavailable) !== null && _h !== void 0 ? _h : false;
this.memberCount = this.members.size;
this.maxPresences = (_j = this.data.max_presences) !== null && _j !== void 0 ? _j : undefined;
this.maxMembers = this.data.max_members;
this.vanityCode = (_k = this.data.vanity_url_code) !== null && _k !== void 0 ? _k : undefined;
this.description = (_l = this.data.description) !== null && _l !== void 0 ? _l : undefined;
this.banner = (_m = this.data.banner) !== null && _m !== void 0 ? _m : undefined;
this.premiumTier = this.data.premium_tier;
this.premiumSubCount = (_o = this.data.premium_subscription_count) !== null && _o !== void 0 ? _o : 0;
this.preferredLang = this.data.preferred_locale;
this.updatesChannelId = (_p = this.data.public_updates_channel_id) !== null && _p !== void 0 ? _p : undefined;
this.maxChannelUsers = this.data.max_video_channel_users;
return this;
}
}
exports.Guild = Guild;