mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 00:23:30 +01:00
add ClientUser#fetchMentions (#999)
* add ClientUser#fetchMentions Signed-off-by: Gus Caplan <gus@localhost.localdomain> * ugh * Update ClientUser.js * Update ClientUser.js * Update ClientUser.js
This commit is contained in:
committed by
Schuyler Cebulskie
parent
a0a3989e59
commit
e392107369
@@ -5,6 +5,7 @@ const parseEmoji = require('../../util/ParseEmoji');
|
||||
|
||||
const User = require('../../structures/User');
|
||||
const GuildMember = require('../../structures/GuildMember');
|
||||
const Message = require('../../structures/Message');
|
||||
const Role = require('../../structures/Role');
|
||||
const Invite = require('../../structures/Invite');
|
||||
const Webhook = require('../../structures/Webhook');
|
||||
@@ -564,6 +565,14 @@ class RESTMethods {
|
||||
);
|
||||
}
|
||||
|
||||
fetchMeMentions(options) {
|
||||
if (options.guild) options.guild = options.guild.id ? options.guild.id : options.guild;
|
||||
return this.rest.makeRequest(
|
||||
'get',
|
||||
Constants.Endpoints.meMentions(options.limit, options.roles, options.everyone, options.guild)
|
||||
).then(res => res.body.map(m => new Message(this.rest.client.channels.get(m.channel_id), m, this.rest.client)));
|
||||
}
|
||||
|
||||
addFriend(user) {
|
||||
return this.rest.makeRequest('post', Constants.Endpoints.relationships('@me'), true, {
|
||||
username: user.username,
|
||||
|
||||
@@ -146,6 +146,19 @@ class ClientUser extends User {
|
||||
return this.setPresence({ afk });
|
||||
}
|
||||
|
||||
/**
|
||||
* Fetches messages that mentioned the client's user
|
||||
* @param {Object} [options] Options for the fetch
|
||||
* @param {number} [options.limit=25] Maximum number of mentions to retrieve
|
||||
* @param {boolean} [options.roles=true] Whether to include role mentions
|
||||
* @param {boolean} [options.everyone=true] Whether to include everyone/here mentions
|
||||
* @param {Guild|string} [options.guild] Limit the search to a specific guild
|
||||
* @returns {Promise<Message[]>}
|
||||
*/
|
||||
fetchMentions(options = { limit: 25, roles: true, everyone: true, guild: null }) {
|
||||
return this.client.rest.methods.fetchMentions(options);
|
||||
}
|
||||
|
||||
/**
|
||||
* Send a friend request
|
||||
* <warn>This is only available when using a user account.</warn>
|
||||
|
||||
@@ -92,6 +92,8 @@ const Endpoints = exports.Endpoints = {
|
||||
avatar: (userID, avatar) => userID === '1' ? avatar : `${Endpoints.user(userID)}/avatars/${avatar}.jpg`,
|
||||
me: `${API}/users/@me`,
|
||||
meGuild: (guildID) => `${Endpoints.me}/guilds/${guildID}`,
|
||||
meMentions: (limit, roles, everyone, guildID) =>
|
||||
`users/@me/mentions?limit=${limit}&roles=${roles}&everyone=${everyone}${guildID ? `&guild_id=${guildID}` : ''}`,
|
||||
relationships: (userID) => `${Endpoints.user(userID)}/relationships`,
|
||||
note: (userID) => `${Endpoints.me}/notes/${userID}`,
|
||||
|
||||
|
||||
Reference in New Issue
Block a user