src: add news and store channels, and missing guild props (#3168)

* src: Implement store and news channels!

* src: Remove code dupe

* src: Add missing guild properties

* docs: Add a small notice that the channel type may also change

* src: Remove re-creation of the MessageStore

* lint: Unused Import

* src: Requested changes for StoreChannels

* typings: Fix typings

* src: Moar guild updates

* src: Set maximumPresence to the data prop, the already existent one, or default to 5000

* typings: afkChannel is a VC

I keep confusing them, ffs

Co-Authored-By: vladfrangu <kingdgrizzle@gmail.com>

* docs: Document that maximumMembers and maximumPresences may be inaccurate before fetching

* src Appels requested changes
This commit is contained in:
Vlad Frangu
2019-05-03 18:08:07 +03:00
committed by SpaceEEC
parent 0d9bc8664d
commit a59968f7de
10 changed files with 195 additions and 8 deletions

View File

@@ -186,6 +186,27 @@ class Guild extends Base {
*/
this.embedEnabled = data.embed_enabled;
/**
* Whether widget images are enabled on this guild
* @type {?boolean}
* @name Guild#widgetEnabled
*/
if (typeof data.widget_enabled !== 'undefined') this.widgetEnabled = data.widget_enabled;
/**
* The widget channel ID, if enabled
* @type {?string}
* @name Guild#widgetChannelID
*/
if (typeof data.widget_channel_id !== 'undefined') this.widgetChannelID = data.widget_channel_id;
/**
* The embed channel ID, if enabled
* @type {?string}
* @name Guild#embedChannelID
*/
if (typeof data.embed_channel_id !== 'undefined') this.embedChannelID = data.embed_channel_id;
/**
* The verification level of the guild
* @type {number}
@@ -211,12 +232,46 @@ class Guild extends Base {
this.joinedTimestamp = data.joined_at ? new Date(data.joined_at).getTime() : this.joinedTimestamp;
/**
* The value set for a guild's default message notifications
* The value set for the guild's default message notifications
* @type {DefaultMessageNotifications|number}
*/
this.defaultMessageNotifications = DefaultMessageNotifications[data.default_message_notifications] ||
data.default_message_notifications;
/**
* The maximum amount of members the guild can have
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @type {?number}
* @name Guild#maximumMembers
*/
if (typeof data.max_members !== 'undefined') this.maximumMembers = data.max_members || 250000;
/**
* The maximum amount of presences the guild can have
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
* @type {?number}
* @name Guild#maximumPresences
*/
if (typeof data.max_presences !== 'undefined') this.maximumPresences = data.max_presences || 5000;
/**
* The vanity URL code of the guild, if any
* @type {?string}
*/
this.vanityURLCode = data.vanity_url_code;
/**
* The description of the guild, if any
* @type {?string}
*/
this.description = data.description;
/**
* The hash of the guild banner
* @type {?string}
*/
this.banner = data.banner;
this.id = data.id;
this.available = !data.unavailable;
this.features = data.features || this.features || [];
@@ -274,6 +329,16 @@ class Guild extends Base {
}
}
/**
* The URL to this guild's banner.
* @param {ImageURLOptions} [options={}] Options for the Image URL
* @returns {?string}
*/
bannerURL({ format, size } = {}) {
if (!this.banner) return null;
return this.client.rest.cdn.Banner(this.id, this.banner, format, size);
}
/**
* The timestamp the guild was created at
* @type {number}
@@ -368,6 +433,24 @@ class Guild extends Base {
return this.client.channels.get(this.systemChannelID) || null;
}
/**
* Widget channel for this guild
* @type {?TextChannel}
* @readonly
*/
get widgetChannel() {
return this.client.channels.get(this.widgetChannelID) || null;
}
/**
* Embed channel for this guild
* @type {?TextChannel}
* @readonly
*/
get embedChannel() {
return this.client.channels.get(this.embedChannelID) || null;
}
/**
* The `@everyone` role of the guild
* @type {?Role}
@@ -409,6 +492,17 @@ class Guild extends Base {
return this.members.resolve(user);
}
/**
* Fetches this guild.
* @returns {Promise<Guild>}
*/
fetch() {
return this.client.api.guilds(this.id).get().then(data => {
this._patch(data);
return this;
});
}
/**
* An object containing information about a guild member's ban.
* @typedef {Object} BanInfo
@@ -975,6 +1069,7 @@ class Guild extends Base {
});
json.iconURL = this.iconURL();
json.splashURL = this.splashURL();
json.bannerURL = this.bannerURL();
return json;
}