mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-12 01:23:31 +01:00
feat(Guild): add systemChannelFlags (#3559)
* Add systemChannelFlags bitfield to Guild * Implement @vladfrangu's suggestions * fix: apply suggestions, reverse order of flags, reword docs * docs: add SystemCHannelFlagsResolvable typedef Co-authored-by: SpaceEEC <spaceeec@yahoo.com>
This commit is contained in:
@@ -10,6 +10,7 @@ const Collection = require('../util/Collection');
|
||||
const Util = require('../util/Util');
|
||||
const DataResolver = require('../util/DataResolver');
|
||||
const Snowflake = require('../util/Snowflake');
|
||||
const SystemChannelFlags = require('../util/SystemChannelFlags');
|
||||
const GuildMemberStore = require('../stores/GuildMemberStore');
|
||||
const RoleStore = require('../stores/RoleStore');
|
||||
const GuildEmojiStore = require('../stores/GuildEmojiStore');
|
||||
@@ -275,6 +276,12 @@ class Guild extends Base {
|
||||
this.defaultMessageNotifications = DefaultMessageNotifications[data.default_message_notifications] ||
|
||||
data.default_message_notifications;
|
||||
|
||||
/**
|
||||
* The value set for the guild's system channel flags
|
||||
* @type {Readonly<SystemChannelFlags>}
|
||||
*/
|
||||
this.systemChannelFlags = new SystemChannelFlags(data.system_channel_flags).freeze();
|
||||
|
||||
/**
|
||||
* The maximum amount of members the guild can have
|
||||
* <info>You will need to fetch the guild using {@link Guild#fetch} if you want to receive this parameter</info>
|
||||
@@ -773,6 +780,7 @@ class Guild extends Base {
|
||||
* @property {Base64Resolvable} [splash] The splash screen of the guild
|
||||
* @property {Base64Resolvable} [banner] The banner of the guild
|
||||
* @property {DefaultMessageNotifications|number} [defaultMessageNotifications] The default message notifications
|
||||
* @property {SystemChannelFlagsResolvable} [systemChannelFlags] The system channel flags of the guild
|
||||
*/
|
||||
|
||||
/**
|
||||
@@ -813,6 +821,9 @@ class Guild extends Base {
|
||||
DefaultMessageNotifications.indexOf(data.defaultMessageNotifications) :
|
||||
Number(data.defaultMessageNotifications);
|
||||
}
|
||||
if (typeof data.systemChannelFlags !== 'undefined') {
|
||||
_data.systemChannelFlags = SystemChannelFlags.resolve(data.systemChannelFlags);
|
||||
}
|
||||
return this.client.api.guilds(this.id).patch({ data: _data, reason })
|
||||
.then(newData => this.client.actions.GuildUpdate.handle(newData).updated);
|
||||
}
|
||||
@@ -839,6 +850,16 @@ class Guild extends Base {
|
||||
}
|
||||
/* eslint-enable max-len */
|
||||
|
||||
/**
|
||||
* Edits the flags of the default message notifications of the guild.
|
||||
* @param {SystemChannelFlagsResolvable} systemChannelFlags The new flags for the default message notifications
|
||||
* @param {string} [reason] Reason for changing the flags of the default message notifications
|
||||
* @returns {Promise<Guild>}
|
||||
*/
|
||||
setSystemChannelFlags(systemChannelFlags, reason) {
|
||||
return this.edit({ systemChannelFlags }, reason);
|
||||
}
|
||||
|
||||
/**
|
||||
* Edits the name of the guild.
|
||||
* @param {string} name The new name of the guild
|
||||
|
||||
Reference in New Issue
Block a user