mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-16 19:43:29 +01:00
refactor(Guild): remove region from guild and manager methods (#5766)
This commit is contained in:
@@ -140,7 +140,6 @@ class GuildManager extends BaseManager {
|
|||||||
* for the guild
|
* for the guild
|
||||||
* @param {ExplicitContentFilterLevel} [options.explicitContentFilter] The explicit content filter level 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 {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,
|
* @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.
|
* 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
|
* @param {number} [options.systemChannelID] The ID of the system channel
|
||||||
@@ -157,7 +156,6 @@ class GuildManager extends BaseManager {
|
|||||||
defaultMessageNotifications,
|
defaultMessageNotifications,
|
||||||
explicitContentFilter,
|
explicitContentFilter,
|
||||||
icon = null,
|
icon = null,
|
||||||
region,
|
|
||||||
roles = [],
|
roles = [],
|
||||||
systemChannelID,
|
systemChannelID,
|
||||||
systemChannelFlags,
|
systemChannelFlags,
|
||||||
@@ -195,7 +193,6 @@ class GuildManager extends BaseManager {
|
|||||||
.post({
|
.post({
|
||||||
data: {
|
data: {
|
||||||
name,
|
name,
|
||||||
region,
|
|
||||||
icon,
|
icon,
|
||||||
verification_level: verificationLevel,
|
verification_level: verificationLevel,
|
||||||
default_message_notifications: defaultMessageNotifications,
|
default_message_notifications: defaultMessageNotifications,
|
||||||
|
|||||||
@@ -6,7 +6,6 @@ const GuildPreview = require('./GuildPreview');
|
|||||||
const GuildTemplate = require('./GuildTemplate');
|
const GuildTemplate = require('./GuildTemplate');
|
||||||
const Integration = require('./Integration');
|
const Integration = require('./Integration');
|
||||||
const Invite = require('./Invite');
|
const Invite = require('./Invite');
|
||||||
const VoiceRegion = require('./VoiceRegion');
|
|
||||||
const Webhook = require('./Webhook');
|
const Webhook = require('./Webhook');
|
||||||
const { Error, TypeError } = require('../errors');
|
const { Error, TypeError } = require('../errors');
|
||||||
const GuildApplicationCommandManager = require('../managers/GuildApplicationCommandManager');
|
const GuildApplicationCommandManager = require('../managers/GuildApplicationCommandManager');
|
||||||
@@ -141,12 +140,6 @@ class Guild extends BaseGuild {
|
|||||||
*/
|
*/
|
||||||
this.discoverySplash = data.discovery_splash;
|
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
|
* The full amount of members in this guild
|
||||||
* @type {number}
|
* @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
|
* Data for the Guild Widget object
|
||||||
* @typedef {Object} GuildWidget
|
* @typedef {Object} GuildWidget
|
||||||
@@ -818,7 +796,6 @@ class Guild extends BaseGuild {
|
|||||||
* The data for editing a guild.
|
* The data for editing a guild.
|
||||||
* @typedef {Object} GuildEditData
|
* @typedef {Object} GuildEditData
|
||||||
* @property {string} [name] The name of the guild
|
* @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 {VerificationLevel|number} [verificationLevel] The verification level of the guild
|
||||||
* @property {ExplicitContentFilterLevel|number} [explicitContentFilter] The level of the explicit content filter
|
* @property {ExplicitContentFilterLevel|number} [explicitContentFilter] The level of the explicit content filter
|
||||||
* @property {ChannelResolvable} [afkChannel] The AFK channel of the guild
|
* @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
|
* @param {string} [reason] Reason for editing this guild
|
||||||
* @returns {Promise<Guild>}
|
* @returns {Promise<Guild>}
|
||||||
* @example
|
* @example
|
||||||
* // Set the guild name and region
|
* // Set the guild name
|
||||||
* guild.edit({
|
* guild.edit({
|
||||||
* name: 'Discord Guild',
|
* 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);
|
* .catch(console.error);
|
||||||
*/
|
*/
|
||||||
edit(data, reason) {
|
edit(data, reason) {
|
||||||
const _data = {};
|
const _data = {};
|
||||||
if (data.name) _data.name = data.name;
|
if (data.name) _data.name = data.name;
|
||||||
if (data.region) _data.region = data.region;
|
|
||||||
if (typeof data.verificationLevel !== 'undefined') {
|
if (typeof data.verificationLevel !== 'undefined') {
|
||||||
_data.verification_level =
|
_data.verification_level =
|
||||||
typeof data.verificationLevel === 'number'
|
typeof data.verificationLevel === 'number'
|
||||||
@@ -955,21 +930,6 @@ class Guild extends BaseGuild {
|
|||||||
return this.edit({ name }, reason);
|
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.
|
* Edits the verification level of the guild.
|
||||||
* @param {VerificationLevel|number} verificationLevel The new 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.available === guild.available &&
|
||||||
this.splash === guild.splash &&
|
this.splash === guild.splash &&
|
||||||
this.discoverySplash === guild.discoverySplash &&
|
this.discoverySplash === guild.discoverySplash &&
|
||||||
this.region === guild.region &&
|
|
||||||
this.name === guild.name &&
|
this.name === guild.name &&
|
||||||
this.memberCount === guild.memberCount &&
|
this.memberCount === guild.memberCount &&
|
||||||
this.large === guild.large &&
|
this.large === guild.large &&
|
||||||
|
|||||||
4
typings/index.d.ts
vendored
4
typings/index.d.ts
vendored
@@ -768,7 +768,6 @@ declare module 'discord.js' {
|
|||||||
public presences: PresenceManager;
|
public presences: PresenceManager;
|
||||||
public readonly publicUpdatesChannel: TextChannel | null;
|
public readonly publicUpdatesChannel: TextChannel | null;
|
||||||
public publicUpdatesChannelID: Snowflake | null;
|
public publicUpdatesChannelID: Snowflake | null;
|
||||||
public region: string;
|
|
||||||
public roles: RoleManager;
|
public roles: RoleManager;
|
||||||
public readonly rulesChannel: TextChannel | null;
|
public readonly rulesChannel: TextChannel | null;
|
||||||
public rulesChannelID: Snowflake | null;
|
public rulesChannelID: Snowflake | null;
|
||||||
@@ -823,7 +822,6 @@ declare module 'discord.js' {
|
|||||||
public setOwner(owner: GuildMemberResolvable, reason?: string): Promise<Guild>;
|
public setOwner(owner: GuildMemberResolvable, reason?: string): Promise<Guild>;
|
||||||
public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>;
|
public setPreferredLocale(preferredLocale: string, reason?: string): Promise<Guild>;
|
||||||
public setPublicUpdatesChannel(publicUpdatesChannel: ChannelResolvable | null, 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 setRolePositions(rolePositions: readonly RolePosition[]): Promise<Guild>;
|
||||||
public setRulesChannel(rulesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
|
public setRulesChannel(rulesChannel: ChannelResolvable | null, reason?: string): Promise<Guild>;
|
||||||
public setSplash(splash: Base64Resolvable | 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;
|
defaultMessageNotifications?: DefaultMessageNotifications | number;
|
||||||
explicitContentFilter?: ExplicitContentFilterLevel | number;
|
explicitContentFilter?: ExplicitContentFilterLevel | number;
|
||||||
icon?: BufferResolvable | Base64Resolvable | null;
|
icon?: BufferResolvable | Base64Resolvable | null;
|
||||||
region?: string;
|
|
||||||
roles?: PartialRoleData[];
|
roles?: PartialRoleData[];
|
||||||
systemChannelFlags?: SystemChannelFlagsResolvable;
|
systemChannelFlags?: SystemChannelFlagsResolvable;
|
||||||
systemChannelID?: number;
|
systemChannelID?: number;
|
||||||
@@ -2976,7 +2973,6 @@ declare module 'discord.js' {
|
|||||||
|
|
||||||
interface GuildEditData {
|
interface GuildEditData {
|
||||||
name?: string;
|
name?: string;
|
||||||
region?: string;
|
|
||||||
verificationLevel?: VerificationLevel | number;
|
verificationLevel?: VerificationLevel | number;
|
||||||
explicitContentFilter?: ExplicitContentFilterLevel | number;
|
explicitContentFilter?: ExplicitContentFilterLevel | number;
|
||||||
defaultMessageNotifications?: DefaultMessageNotifications | number;
|
defaultMessageNotifications?: DefaultMessageNotifications | number;
|
||||||
|
|||||||
Reference in New Issue
Block a user