discord.js-selfbot-v13/src/structures/AnonymousGuild.js

89 lines
2.1 KiB
JavaScript
Raw Normal View History

2022-03-19 10:37:45 +00:00
'use strict';
const BaseGuild = require('./BaseGuild');
const { VerificationLevels, NSFWLevels } = require('../util/Constants');
2022-03-19 10:37:45 +00:00
/**
* Bundles common attributes and methods between {@link Guild} and {@link InviteGuild}
* @extends {BaseGuild}
* @abstract
*/
class AnonymousGuild extends BaseGuild {
constructor(client, data, immediatePatch = true) {
super(client, data);
if (immediatePatch) this._patch(data);
}
_patch(data) {
if ('features' in data) this.features = data.features;
if ('splash' in data) {
/**
* The hash of the guild invite splash image
* @type {?string}
*/
this.splash = data.splash;
}
if ('banner' in data) {
/**
* The hash of the guild banner
* @type {?string}
*/
this.banner = data.banner;
}
if ('description' in data) {
/**
* The description of the guild, if any
* @type {?string}
*/
this.description = data.description;
}
if ('verification_level' in data) {
/**
* The verification level of the guild
* @type {VerificationLevel}
2022-03-19 10:37:45 +00:00
*/
this.verificationLevel = VerificationLevels[data.verification_level];
2022-03-19 10:37:45 +00:00
}
if ('vanity_url_code' in data) {
/**
* The vanity invite code of the guild, if any
* @type {?string}
*/
this.vanityURLCode = data.vanity_url_code;
}
if ('nsfw_level' in data) {
/**
* The NSFW level of this guild
* @type {NSFWLevel}
2022-03-19 10:37:45 +00:00
*/
this.nsfwLevel = NSFWLevels[data.nsfw_level];
2022-03-19 10:37:45 +00:00
}
}
/**
* The URL to this guild's banner.
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
2022-03-19 10:37:45 +00:00
* @returns {?string}
*/
bannerURL({ format, size } = {}) {
return this.banner && this.client.rest.cdn.Banner(this.id, this.banner, format, size);
2022-03-19 10:37:45 +00:00
}
/**
* The URL to this guild's invite splash image.
* @param {StaticImageURLOptions} [options={}] Options for the Image URL
2022-03-19 10:37:45 +00:00
* @returns {?string}
*/
splashURL({ format, size } = {}) {
return this.splash && this.client.rest.cdn.Splash(this.id, this.splash, format, size);
2022-03-19 10:37:45 +00:00
}
}
module.exports = AnonymousGuild;