From 30c7d6d1b16a336a1ff37cac23fc5dfe3c952417 Mon Sep 17 00:00:00 2001 From: Kyra Date: Tue, 29 May 2018 00:44:04 +0200 Subject: [PATCH] feat(Guild#defaultMessageNotifications) (#2538) * feat(Guild#defaultMessageNotifications) * boolean -> DefaultMessageNotifications * Space's requested change --- src/structures/Guild.js | 9 ++++++++- src/util/Constants.js | 11 +++++++++++ 2 files changed, 19 insertions(+), 1 deletion(-) diff --git a/src/structures/Guild.js b/src/structures/Guild.js index e507bd20351f..d60927e0cfae 100644 --- a/src/structures/Guild.js +++ b/src/structures/Guild.js @@ -2,7 +2,7 @@ const Invite = require('./Invite'); const GuildAuditLogs = require('./GuildAuditLogs'); const Webhook = require('./Webhook'); const VoiceRegion = require('./VoiceRegion'); -const { ChannelTypes, Events, browser } = require('../util/Constants'); +const { ChannelTypes, DefaultMessageNotifications, Events, browser } = require('../util/Constants'); const Collection = require('../util/Collection'); const Util = require('../util/Util'); const DataResolver = require('../util/DataResolver'); @@ -188,6 +188,13 @@ class Guild extends Base { */ this.joinedTimestamp = data.joined_at ? new Date(data.joined_at).getTime() : this.joinedTimestamp; + /** + * The value set for a guild's default message notifications + * @type {DefaultMessageNotifications|number} + */ + this.defaultMessageNotifications = DefaultMessageNotifications[data.default_message_notifications] || + data.default_message_notifications; + this.id = data.id; this.available = !data.unavailable; this.features = data.features || this.features || []; diff --git a/src/util/Constants.js b/src/util/Constants.js index 65b275a358df..729448d7ac9e 100644 --- a/src/util/Constants.js +++ b/src/util/Constants.js @@ -725,6 +725,17 @@ exports.APIErrors = { REACTION_BLOCKED: 90001, }; +/** + * The value set for a guild's default message notifications, e.g. `ALL`. Here are the available types: + * * ALL + * * MENTIONS + * @typedef {string} DefaultMessageNotifications + */ +exports.DefaultMessageNotifications = [ + 'ALL', + 'MENTIONS', +]; + function keyMirror(arr) { let tmp = Object.create(null); for (const value of arr) tmp[value] = value;