mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
backport: DefaultMessageNotifications
This commit is contained in:
@@ -74,6 +74,7 @@ class Guild {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable complexity */
|
||||||
/**
|
/**
|
||||||
* Sets up the guild.
|
* Sets up the guild.
|
||||||
* @param {*} data The raw data of the guild
|
* @param {*} data The raw data of the guild
|
||||||
@@ -176,6 +177,13 @@ class Guild {
|
|||||||
*/
|
*/
|
||||||
this.joinedTimestamp = data.joined_at ? new Date(data.joined_at).getTime() : this.joinedTimestamp;
|
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 = Constants.DefaultMessageNotifications[data.default_message_notifications] ||
|
||||||
|
data.default_message_notifications;
|
||||||
|
|
||||||
this.id = data.id;
|
this.id = data.id;
|
||||||
this.available = !data.unavailable;
|
this.available = !data.unavailable;
|
||||||
this.features = data.features || this.features || [];
|
this.features = data.features || this.features || [];
|
||||||
@@ -688,6 +696,11 @@ class Guild {
|
|||||||
if (typeof data.explicitContentFilter !== 'undefined') {
|
if (typeof data.explicitContentFilter !== 'undefined') {
|
||||||
_data.explicit_content_filter = Number(data.explicitContentFilter);
|
_data.explicit_content_filter = Number(data.explicitContentFilter);
|
||||||
}
|
}
|
||||||
|
if (typeof data.defaultMessageNotifications !== 'undefined') {
|
||||||
|
_data.default_message_notifications = typeof data.defaultMessageNotifications === 'string' ?
|
||||||
|
Constants.DefaultMessageNotifications.indexOf(data.defaultMessageNotifications) :
|
||||||
|
Number(data.defaultMessageNotifications);
|
||||||
|
}
|
||||||
return this.client.rest.methods.updateGuild(this, _data, reason);
|
return this.client.rest.methods.updateGuild(this, _data, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -701,6 +714,17 @@ class Guild {
|
|||||||
return this.edit({ explicitContentFilter }, reason);
|
return this.edit({ explicitContentFilter }, reason);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* eslint-disable max-len */
|
||||||
|
/**
|
||||||
|
* Edits the setting of the default message notifications of the guild.
|
||||||
|
* @param {DefaultMessageNotifications|number} defaultMessageNotifications The new setting for the default message notifications
|
||||||
|
* @param {string} [reason] Reason for changing the setting of the default message notifications
|
||||||
|
* @returns {Promise<Guild>}
|
||||||
|
*/
|
||||||
|
setDefaultMessageNotifications(defaultMessageNotifications, reason) {
|
||||||
|
return this.edit({ defaultMessageNotifications }, reason);
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Edit the name of the guild.
|
* Edit the name of the guild.
|
||||||
* @param {string} name The new name of the guild
|
* @param {string} name The new name of the guild
|
||||||
|
|||||||
@@ -815,3 +815,14 @@ exports.APIErrors = {
|
|||||||
INVITE_ACCEPTED_TO_GUILD_NOT_CONTANING_BOT: 50036,
|
INVITE_ACCEPTED_TO_GUILD_NOT_CONTANING_BOT: 50036,
|
||||||
REACTION_BLOCKED: 90001,
|
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',
|
||||||
|
];
|
||||||
|
|||||||
Reference in New Issue
Block a user