Skip to content

Commit

Permalink
refactor(Guild): remove region from guild and manager methods (#5766)
Browse files Browse the repository at this point in the history
  • Loading branch information
almostSouji committed Jun 10, 2021
1 parent fbcbb29 commit a1f763e
Show file tree
Hide file tree
Showing 3 changed files with 2 additions and 50 deletions.
3 changes: 0 additions & 3 deletions src/managers/GuildManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand All @@ -157,7 +156,6 @@ class GuildManager extends BaseManager {
defaultMessageNotifications,
explicitContentFilter,
icon = null,
region,
roles = [],
systemChannelID,
systemChannelFlags,
Expand Down Expand Up @@ -195,7 +193,6 @@ class GuildManager extends BaseManager {
.post({
data: {
name,
region,
icon,
verification_level: verificationLevel,
default_message_notifications: defaultMessageNotifications,
Expand Down
45 changes: 2 additions & 43 deletions src/structures/Guild.js
Original file line number Diff line number Diff line change
Expand Up @@ -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');
Expand Down Expand Up @@ -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}
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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'
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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 &&
Expand Down
4 changes: 0 additions & 4 deletions typings/index.d.ts
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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>;
Expand Down Expand Up @@ -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;
Expand All @@ -2976,7 +2973,6 @@ declare module 'discord.js' {

interface GuildEditData {
name?: string;
region?: string;
verificationLevel?: VerificationLevel | number;
explicitContentFilter?: ExplicitContentFilterLevel | number;
defaultMessageNotifications?: DefaultMessageNotifications | number;
Expand Down

0 comments on commit a1f763e

Please sign in to comment.