refactor: switch api and gateway to V8 (#4879)

Co-authored-by: Jan <66554238+Vaporox@users.noreply.github.com>
This commit is contained in:
Sugden
2021-02-11 17:10:35 +00:00
committed by GitHub
parent ae3c3d80ee
commit ee5bc1a5c4
33 changed files with 372 additions and 364 deletions

View File

@@ -210,13 +210,6 @@ class Guild extends Base {
*/
this.systemChannelID = data.system_channel_id;
/**
* Whether embedded images are enabled on this guild
* @type {boolean}
* @deprecated
*/
this.embedEnabled = data.embed_enabled;
/**
* The type of premium tier:
* * 0: NONE
@@ -256,15 +249,6 @@ class Guild extends Base {
this.widgetChannelID = data.widget_channel_id;
}
if (typeof data.embed_channel_id !== 'undefined') {
/**
* The embed channel ID, if enabled
* @type {?string}
* @deprecated
*/
this.embedChannelID = data.embed_channel_id;
}
/**
* The verification level of the guild
* @type {VerificationLevel}
@@ -585,16 +569,6 @@ class Guild extends Base {
return this.client.channels.cache.get(this.widgetChannelID) || null;
}
/**
* Embed channel for this guild
* @type {?TextChannel}
* @readonly
* @deprecated
*/
get embedChannel() {
return this.client.channels.cache.get(this.embedChannelID) || null;
}
/**
* Rules channel for this guild
* @type {?TextChannel}
@@ -688,8 +662,6 @@ class Guild extends Base {
/**
* Fetches a collection of integrations to this guild.
* Resolves with a collection mapping integrations by their ids.
* @param {Object} [options] Options for fetching integrations
* @param {boolean} [options.includeApplications] Whether to include bot and Oauth2 webhook integrations
* @returns {Promise<Collection<string, Integration>>}
* @example
* // Fetch integrations
@@ -697,20 +669,12 @@ class Guild extends Base {
* .then(integrations => console.log(`Fetched ${integrations.size} integrations`))
* .catch(console.error);
*/
fetchIntegrations({ includeApplications = false } = {}) {
return this.client.api
.guilds(this.id)
.integrations.get({
query: {
include_applications: includeApplications,
},
})
.then(data =>
data.reduce(
(collection, integration) => collection.set(integration.id, new Integration(this.client, integration, this)),
new Collection(),
),
);
async fetchIntegrations() {
const data = await this.client.api.guilds(this.id).integrations.get();
return data.reduce(
(collection, integration) => collection.set(integration.id, new Integration(this.client, integration, this)),
new Collection(),
);
}
/**
@@ -895,20 +859,6 @@ class Guild extends Base {
* @property {?GuildChannelResolvable} channel The widget channel
*/
/**
* Fetches the guild embed.
* @returns {Promise<GuildWidget>}
* @deprecated
* @example
* // Fetches the guild embed
* guild.fetchEmbed()
* .then(embed => console.log(`The embed is ${embed.enabled ? 'enabled' : 'disabled'}`))
* .catch(console.error);
*/
fetchEmbed() {
return this.fetchWidget();
}
/**
* Fetches the guild widget.
* @returns {Promise<GuildWidget>}
@@ -920,8 +870,8 @@ class Guild extends Base {
*/
async fetchWidget() {
const data = await this.client.api.guilds(this.id).widget.get();
this.widgetEnabled = this.embedEnabled = data.enabled;
this.widgetChannelID = this.embedChannelID = data.channel_id;
this.widgetEnabled = data.enabled;
this.widgetChannelID = data.channel_id;
return {
enabled: data.enabled,
channel: data.channel_id ? this.channels.cache.get(data.channel_id) : null,
@@ -1367,7 +1317,7 @@ class Guild extends Base {
* @returns {Promise<Guild>}
* @example
* guild.setRolePositions([{ role: roleID, position: updatedRoleIndex }])
* .then(guild => console.log(`Role permissions updated for ${guild}`))
* .then(guild => console.log(`Role positions updated for ${guild}`))
* .catch(console.error);
*/
setRolePositions(rolePositions) {
@@ -1392,17 +1342,6 @@ class Guild extends Base {
);
}
/**
* Edits the guild's embed.
* @param {GuildWidgetData} embed The embed for the guild
* @param {string} [reason] Reason for changing the guild's embed
* @returns {Promise<Guild>}
* @deprecated
*/
setEmbed(embed, reason) {
return this.setWidget(embed, reason);
}
/**
* Edits the guild's widget.
* @param {GuildWidgetData} widget The widget for the guild
@@ -1464,7 +1403,7 @@ class Guild extends Base {
* @returns {boolean}
*/
equals(guild) {
let equal =
return (
guild &&
guild instanceof this.constructor &&
this.id === guild.id &&
@@ -1478,20 +1417,10 @@ class Guild extends Base {
this.icon === guild.icon &&
this.ownerID === guild.ownerID &&
this.verificationLevel === guild.verificationLevel &&
this.embedEnabled === guild.embedEnabled &&
(this.features === guild.features ||
(this.features.length === guild.features.length &&
this.features.every((feat, i) => feat === guild.features[i])));
if (equal) {
if (this.embedChannel) {
if (!guild.embedChannel || this.embedChannel.id !== guild.embedChannel.id) equal = false;
} else if (guild.embedChannel) {
equal = false;
}
}
return equal;
this.features.every((feat, i) => feat === guild.features[i])))
);
}
/**
@@ -1522,7 +1451,7 @@ class Guild extends Base {
/**
* Creates a collection of this guild's roles, sorted by their position and IDs.
* @returns {Collection<Role>}
* @returns {Collection<Snowflake, Role>}
* @private
*/
_sortedRoles() {
@@ -1532,7 +1461,7 @@ class Guild extends Base {
/**
* Creates a collection of this guild's or a specific category's channels, sorted by their position and IDs.
* @param {GuildChannel} [channel] Category to get the channels of
* @returns {Collection<GuildChannel>}
* @returns {Collection<Snowflake, GuildChannel>}
* @private
*/
_sortedChannels(channel) {
@@ -1549,10 +1478,6 @@ class Guild extends Base {
}
}
Guild.prototype.setEmbed = deprecate(Guild.prototype.setEmbed, 'Guild#setEmbed: Use setWidget instead');
Guild.prototype.fetchEmbed = deprecate(Guild.prototype.fetchEmbed, 'Guild#fetchEmbed: Use fetchWidget instead');
Guild.prototype.fetchVanityCode = deprecate(
Guild.prototype.fetchVanityCode,
'Guild#fetchVanityCode: Use fetchVanityData() instead',