seyfert
Version:
The most advanced framework for discord bots
99 lines (98 loc) • 2.98 kB
JavaScript
"use strict";
Object.defineProperty(exports, "__esModule", { value: true });
exports.BaseGuild = void 0;
const common_1 = require("../../common");
const types_1 = require("../../types");
const DiscordBase_1 = require("./DiscordBase");
/**
* Base guild class
*/
class BaseGuild extends DiscordBase_1.DiscordBase {
get partnered() {
if (!this.features) {
return false;
}
return this.features.includes(types_1.GuildFeature.Partnered);
}
/**
* If the guild is verified.
* @link https://discord.com/developers/docs/resources/guild#guild-object-guild-features
*/
get verified() {
if (!this.features) {
return false;
}
return this.features.includes(types_1.GuildFeature.Verified);
}
/**
* Fetch guild on API
*/
async fetch() {
const data = await this.api.guilds(this.id).get();
return new BaseGuild(this.client, data);
}
/**
* iconURL gets the current guild icon.
* @link https://discord.com/developers/docs/reference#image-formatting
*/
iconURL(options) {
if (!this.icon) {
return;
}
return this.rest.cdn.icons(this.id).get(this.icon, options);
}
/**
* splashURL gets the current guild splash as a string.
* @link https://discord.com/developers/docs/reference#image-formatting
* @param options - Image options for the splash url.
* @returns Splash url or void.
*/
splashURL(options) {
if (!this.splash) {
return;
}
return this.rest.cdn['discovery-splashes'](this.id).get(this.splash, options);
}
/**
* bannerURL gets the current guild banner as a string.
* @link https://discord.com/developers/docs/reference#image-formatting
* @param options - Image options for the banner url.
* @returns Banner url or void
*/
bannerURL(options) {
if (!this.banner) {
return;
}
return this.rest.cdn.banners(this.id).get(this.banner, options);
}
/**
* Shard ID of the guild.
* @returns Shard ID or -1 if the client is not gateway based.
*/
get shardId() {
if ('gateway' in this.client) {
return this.client.gateway.calculateShardId(this.id);
}
if ('shards' in this.client) {
return (0, common_1.calculateShardId)(this.id, this.client.workerData.totalShards);
}
return -1;
}
/**
* Shard of the guild.
* @returns Shard or undefined, if the client is not gateway based always undefined.
*/
get shard() {
if ('gateway' in this.client) {
return this.client.gateway.get(this.shardId);
}
if ('shards' in this.client) {
return this.client.shards.get(this.shardId);
}
return undefined;
}
toString() {
return this.name;
}
}
exports.BaseGuild = BaseGuild;