refactor(Guild): remove region from guild and manager methods (#5766)

This commit is contained in:
Souji
2021-06-10 16:09:57 +02:00
committed by GitHub
parent fbcbb29884
commit a1f763ee75
3 changed files with 2 additions and 50 deletions

View File

@@ -140,7 +140,6 @@ class GuildManager extends BaseManager {
* for the guild
* @param {ExplicitContentFilterLevel} [options.explicitContentFilter] The explicit content filter level for the guild
* @param {BufferResolvable|Base64Resolvable} [options.icon=null] The icon for the guild
* @param {string} [options.region] The region for the server, defaults to the closest one available
* @param {PartialRoleData[]} [options.roles] The roles for this guild,
* the first element of this array is used to change properties of the guild's everyone role.
* @param {number} [options.systemChannelID] The ID of the system channel
@@ -157,7 +156,6 @@ class GuildManager extends BaseManager {
defaultMessageNotifications,
explicitContentFilter,
icon = null,
region,
roles = [],
systemChannelID,
systemChannelFlags,
@@ -195,7 +193,6 @@ class GuildManager extends BaseManager {
.post({
data: {
name,
region,
icon,
verification_level: verificationLevel,
default_message_notifications: defaultMessageNotifications,

View File

@@ -6,7 +6,6 @@ const GuildPreview = require('./GuildPreview');
const GuildTemplate = require('./GuildTemplate');
const Integration = require('./Integration');
const Invite = require('./Invite');
const VoiceRegion = require('./VoiceRegion');
const Webhook = require('./Webhook');
const { Error, TypeError } = require('../errors');
const GuildApplicationCommandManager = require('../managers/GuildApplicationCommandManager');
@@ -141,12 +140,6 @@ class Guild extends BaseGuild {
*/
this.discoverySplash = data.discovery_splash;
/**
* The region the guild is located in
* @type {string}
*/
this.region = data.region;
/**
* The full amount of members in this guild
* @type {number}
@@ -700,21 +693,6 @@ class Guild extends BaseGuild {
});
}
/**
* Fetches available voice regions.
* @returns {Promise<Collection<string, VoiceRegion>>}
*/
fetchVoiceRegions() {
return this.client.api
.guilds(this.id)
.regions.get()
.then(res => {
const regions = new Collection();
for (const region of res) regions.set(region.id, new VoiceRegion(region));
return regions;
});
}
/**
* Data for the Guild Widget object
* @typedef {Object} GuildWidget
@@ -818,7 +796,6 @@ class Guild extends BaseGuild {
* The data for editing a guild.
* @typedef {Object} GuildEditData
* @property {string} [name] The name of the guild
* @property {string} [region] The region of the guild
* @property {VerificationLevel|number} [verificationLevel] The verification level of the guild
* @property {ExplicitContentFilterLevel|number} [explicitContentFilter] The level of the explicit content filter
* @property {ChannelResolvable} [afkChannel] The AFK channel of the guild
@@ -844,18 +821,16 @@ class Guild extends BaseGuild {
* @param {string} [reason] Reason for editing this guild
* @returns {Promise<Guild>}
* @example
* // Set the guild name and region
* // Set the guild name
* guild.edit({
* name: 'Discord Guild',
* region: 'london',
* })
* .then(updated => console.log(`New guild name ${updated} in region ${updated.region}`))
* .then(updated => console.log(`New guild name ${updated}`))
* .catch(console.error);
*/
edit(data, reason) {
const _data = {};
if (data.name) _data.name = data.name;
if (data.region) _data.region = data.region;
if (typeof data.verificationLevel !== 'undefined') {
_data.verification_level =
typeof data.verificationLevel === 'number'
@@ -955,21 +930,6 @@ class Guild extends BaseGuild {
return this.edit({ name }, reason);
}
/**
* Edits the region of the guild.
* @param {string} region The new region of the guild
* @param {string} [reason] Reason for changing the guild's region
* @returns {Promise<Guild>}
* @example
* // Edit the guild region
* guild.setRegion('london')
* .then(updated => console.log(`Updated guild region to ${updated.region}`))
* .catch(console.error);
*/
setRegion(region, reason) {
return this.edit({ region }, reason);
}
/**
* Edits the verification level of the guild.
* @param {VerificationLevel|number} verificationLevel The new verification level of the guild
@@ -1301,7 +1261,6 @@ class Guild extends BaseGuild {
this.available === guild.available &&
this.splash === guild.splash &&
this.discoverySplash === guild.discoverySplash &&
this.region === guild.region &&
this.name === guild.name &&
this.memberCount === guild.memberCount &&
this.large === guild.large &&

4
typings/index.d.ts vendored
View File

@@ -768,7 +768,6 @@ declare module 'discord.js' {
public presences: PresenceManager;
public readonly publicUpdatesChannel: TextChannel | null;
public publicUpdatesChannelID: Snowflake | null;
public region: string;
public roles: RoleManager;
public readonly rulesChannel: TextChannel | null;
public rulesChannelID: Snowflake | null;
@@ -823,7 +822,6 @@ declare module 'discord.js' {
public setOwner(owner: GuildMemberResolvable, reason?: string): Promise<Guild>;
public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>;
public setPublicUpdatesChannel(publicUpdatesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
public setRegion(region: string, reason?: string): Promise<Guild>;
public setRolePositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
public setRulesChannel(rulesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
public setSplash(splash: Base64Resolvable | null, reason?: string): Promise<Guild>;
@@ -2962,7 +2960,6 @@ declare module 'discord.js' {
defaultMessageNotifications?: DefaultMessageNotifications | number;
explicitContentFilter?: ExplicitContentFilterLevel | number;
icon?: BufferResolvable | Base64Resolvable | null;
region?: string;
roles?: PartialRoleData[];
systemChannelFlags?: SystemChannelFlagsResolvable;
systemChannelID?: number;
@@ -2976,7 +2973,6 @@ declare module 'discord.js' {
interface GuildEditData {
name?: string;
region?: string;
verificationLevel?: VerificationLevel | number;
explicitContentFilter?: ExplicitContentFilterLevel | number;
defaultMessageNotifications?: DefaultMessageNotifications | number;