mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
feat(GuildManager): Allow for more options for GuildManager.cre… (#3742)
* typings: add GuildVerificationLevel and GuildExplicitContentFilter * implement new types * fix jsdoc on stores * typo * add more options for GuildStore#create * add channels and roles * update typings * fix typings and use snake case for permissionOverwrites * typings & jsdoc * fix tslint * remove trailing whitespace * fix jsdoc * fix jsdoc * fix oopsies * fix lint * fix lint * fix mr lint man * add typedefs and support for setting channel parents * fix tab indenation * update jsdoc * suggested changes * style: fix silly format * docs(PartialChannelData): name is not optional * style: remove silly format
This commit is contained in:
@@ -5,7 +5,13 @@ const Integration = require('./Integration');
|
||||
const GuildAuditLogs = require('./GuildAuditLogs');
|
||||
const Webhook = require('./Webhook');
|
||||
const VoiceRegion = require('./VoiceRegion');
|
||||
const { ChannelTypes, DefaultMessageNotifications, PartialTypes } = require('../util/Constants');
|
||||
const {
|
||||
ChannelTypes,
|
||||
DefaultMessageNotifications,
|
||||
PartialTypes,
|
||||
VerificationLevels,
|
||||
ExplicitContentFilterLevels,
|
||||
} = require('../util/Constants');
|
||||
const Collection = require('../util/Collection');
|
||||
const Util = require('../util/Util');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
@@ -247,15 +253,15 @@ class Guild extends Base {
|
||||
|
||||
/**
|
||||
* The verification level of the guild
|
||||
* @type {number}
|
||||
* @type {VerificationLevel}
|
||||
*/
|
||||
this.verificationLevel = data.verification_level;
|
||||
this.verificationLevel = VerificationLevels[data.verification_level];
|
||||
|
||||
/**
|
||||
* The explicit content filter level of the guild
|
||||
* @type {number}
|
||||
* @type {ExplicitContentFilterLevel}
|
||||
*/
|
||||
this.explicitContentFilter = data.explicit_content_filter;
|
||||
this.explicitContentFilter = ExplicitContentFilterLevels[data.explicit_content_filter];
|
||||
|
||||
/**
|
||||
* The required MFA level for the guild
|
||||
@@ -821,8 +827,8 @@ class Guild extends Base {
|
||||
* @typedef {Object} GuildEditData
|
||||
* @property {string} [name] The name of the guild
|
||||
* @property {string} [region] The region of the guild
|
||||
* @property {number} [verificationLevel] The verification level of the guild
|
||||
* @property {number} [explicitContentFilter] The level of the explicit content filter
|
||||
* @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
|
||||
* @property {ChannelResolvable} [systemChannel] The system channel of the guild
|
||||
* @property {number} [afkTimeout] The AFK timeout of the guild
|
||||
@@ -852,7 +858,11 @@ class Guild extends Base {
|
||||
const _data = {};
|
||||
if (data.name) _data.name = data.name;
|
||||
if (data.region) _data.region = data.region;
|
||||
if (typeof data.verificationLevel !== 'undefined') _data.verification_level = Number(data.verificationLevel);
|
||||
if (typeof data.verificationLevel !== 'undefined') {
|
||||
_data.verification_level = typeof data.verificationLevel === 'number' ?
|
||||
Number(data.verificationLevel) :
|
||||
ExplicitContentFilterLevels.indexOf(data.verificationLevel);
|
||||
}
|
||||
if (typeof data.afkChannel !== 'undefined') {
|
||||
_data.afk_channel_id = this.client.channels.resolveID(data.afkChannel);
|
||||
}
|
||||
@@ -865,12 +875,14 @@ class Guild extends Base {
|
||||
if (data.splash) _data.splash = data.splash;
|
||||
if (data.banner) _data.banner = data.banner;
|
||||
if (typeof data.explicitContentFilter !== 'undefined') {
|
||||
_data.explicit_content_filter = Number(data.explicitContentFilter);
|
||||
_data.explicit_content_filter = typeof data.explicitContentFilter === 'number' ?
|
||||
data.explicitContentFilter :
|
||||
ExplicitContentFilterLevels.indexOf(data.explicitContentFilter);
|
||||
}
|
||||
if (typeof data.defaultMessageNotifications !== 'undefined') {
|
||||
_data.default_message_notifications = typeof data.defaultMessageNotifications === 'string' ?
|
||||
DefaultMessageNotifications.indexOf(data.defaultMessageNotifications) :
|
||||
Number(data.defaultMessageNotifications);
|
||||
data.defaultMessageNotifications;
|
||||
}
|
||||
if (typeof data.systemChannelFlags !== 'undefined') {
|
||||
_data.system_channel_flags = SystemChannelFlags.resolve(data.systemChannelFlags);
|
||||
@@ -881,7 +893,7 @@ class Guild extends Base {
|
||||
|
||||
/**
|
||||
* Edits the level of the explicit content filter.
|
||||
* @param {number} explicitContentFilter The new level of the explicit content filter
|
||||
* @param {ExplicitContentFilterLevel|number} explicitContentFilter The new level of the explicit content filter
|
||||
* @param {string} [reason] Reason for changing the level of the guild's explicit content filter
|
||||
* @returns {Promise<Guild>}
|
||||
*/
|
||||
@@ -943,7 +955,7 @@ class Guild extends Base {
|
||||
|
||||
/**
|
||||
* Edits the verification level of the guild.
|
||||
* @param {number} verificationLevel The new verification level of the guild
|
||||
* @param {VerificationLevel|number} verificationLevel The new verification level of the guild
|
||||
* @param {string} [reason] Reason for changing the guild's verification level
|
||||
* @returns {Promise<Guild>}
|
||||
* @example
|
||||
|
||||
@@ -211,7 +211,7 @@ class GuildChannel extends Channel {
|
||||
/**
|
||||
* Updates Overwrites for a user or role in this channel. (creates if non-existent)
|
||||
* @param {RoleResolvable|UserResolvable} userOrRole The user or role to update
|
||||
* @param {PermissionOverwriteOption} options The options for the update
|
||||
* @param {PermissionOverwriteOptions} options The options for the update
|
||||
* @param {string} [reason] Reason for creating/editing this overwrite
|
||||
* @returns {Promise<GuildChannel>}
|
||||
* @example
|
||||
@@ -234,7 +234,7 @@ class GuildChannel extends Channel {
|
||||
/**
|
||||
* Overwrites the permissions for a user or role in this channel. (replaces if existent)
|
||||
* @param {RoleResolvable|UserResolvable} userOrRole The user or role to update
|
||||
* @param {PermissionOverwriteOption} options The options for the update
|
||||
* @param {PermissionOverwriteOptions} options The options for the update
|
||||
* @param {string} [reason] Reason for creating/editing this overwrite
|
||||
* @returns {Promise<GuildChannel>}
|
||||
* @example
|
||||
|
||||
@@ -56,7 +56,7 @@ class PermissionOverwrites {
|
||||
|
||||
/**
|
||||
* Updates this permissionOverwrites.
|
||||
* @param {PermissionOverwriteOption} options The options for the update
|
||||
* @param {PermissionOverwriteOptions} options The options for the update
|
||||
* @param {string} [reason] Reason for creating/editing this overwrite
|
||||
* @returns {Promise<PermissionOverwrites>}
|
||||
* @example
|
||||
@@ -99,7 +99,7 @@ class PermissionOverwrites {
|
||||
* 'ATTACH_FILES': false,
|
||||
* }
|
||||
* ```
|
||||
* @typedef {Object} PermissionOverwriteOption
|
||||
* @typedef {Object} PermissionOverwriteOptions
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -110,7 +110,7 @@ class PermissionOverwrites {
|
||||
|
||||
/**
|
||||
* Deletes this Permission Overwrite.
|
||||
* @param {PermissionOverwriteOption} options The options for the update
|
||||
* @param {PermissionOverwriteOptions} options The options for the update
|
||||
* @param {Object} initialPermissions The initial permissions
|
||||
* @param {PermissionResolvable} initialPermissions.allow Initial allowed permissions
|
||||
* @param {PermissionResolvable} initialPermissions.deny Initial denied permissions
|
||||
|
||||
Reference in New Issue
Block a user