From 1e115efa562cf6c195daef14787fdd2ae1a9bd22 Mon Sep 17 00:00:00 2001 From: SpaceEEC Date: Sat, 6 May 2017 01:04:12 +0200 Subject: [PATCH] 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 --- src/client/rest/RESTMethods.js | 9 +++++---- src/structures/ClientUser.js | 2 +- 2 files changed, 6 insertions(+), 5 deletions(-) diff --git a/src/client/rest/RESTMethods.js b/src/client/rest/RESTMethods.js index aa3d0fe8b..7c9030ad4 100644 --- a/src/client/rest/RESTMethods.js +++ b/src/client/rest/RESTMethods.js @@ -764,11 +764,12 @@ class RESTMethods { } 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( - 'get', - Endpoints.User('@me').Mentions(options.limit, options.roles, options.everyone, options.guild) - ).then(res => res.body.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client))); + 'get', Endpoints.User('@me').Mentions(options.limit, options.roles, options.everyone, options.guild), true + ).then(data => data.map(m => new Message(this.client.channels.get(m.channel_id), m, this.client))); } addFriend(user) { diff --git a/src/structures/ClientUser.js b/src/structures/ClientUser.js index 9fe1a3d96..dcd16423c 100644 --- a/src/structures/ClientUser.js +++ b/src/structures/ClientUser.js @@ -265,7 +265,7 @@ class ClientUser extends User { * @param {Guild|Snowflake} [options.guild] Limit the search to a specific guild * @returns {Promise} */ - fetchMentions(options = { limit: 25, roles: true, everyone: true, guild: null }) { + fetchMentions(options = {}) { return this.client.rest.methods.fetchMentions(options); }