fix fetchMentions' auth header, options and data mapping (#1457)

* fix fetchMentions' auth header, options and data mapping

* vscode strikes again

* switched to Util.mergeDefault

* vscode

* removed duplicated optionals and switched to instanceof
This commit is contained in:
SpaceEEC
2017-05-06 01:04:12 +02:00
committed by Crawl
parent d9e5bdea19
commit e66fa145d2
2 changed files with 6 additions and 5 deletions

View File

@@ -764,11 +764,12 @@ class RESTMethods {
} }
fetchMentions(options) { fetchMentions(options) {
if (options.guild) options.guild = options.guild.id ? options.guild.id : options.guild; if (options.guild instanceof Guild) options.guild = options.guild.id;
Util.mergeDefault({ limit: 25, roles: true, everyone: true, guild: null }, options);
return this.rest.makeRequest( return this.rest.makeRequest(
'get', 'get', Endpoints.User('@me').Mentions(options.limit, options.roles, options.everyone, options.guild), true
Endpoints.User('@me').Mentions(options.limit, options.roles, options.everyone, options.guild) ).then(data => data.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client)));
).then(res => res.body.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client)));
} }
addFriend(user) { addFriend(user) {

View File

@@ -265,7 +265,7 @@ class ClientUser extends User {
* @param {Guild|Snowflake} [options.guild] Limit the search to a specific guild * @param {Guild|Snowflake} [options.guild] Limit the search to a specific guild
* @returns {Promise<Message[]>} * @returns {Promise<Message[]>}
*/ */
fetchMentions(options = { limit: 25, roles: true, everyone: true, guild: null }) { fetchMentions(options = {}) {
return this.client.rest.methods.fetchMentions(options); return this.client.rest.methods.fetchMentions(options);
} }