mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-10 08:33:30 +01:00
Partials (#3070)
* Remove GroupDMChannels they sparked no joy * Start partials for message deletion * MessageUpdate partials * Add partials as an opt-in client option * Add fetch() to Message * Message.author should never be undefined * Fix channels being the wrong type * Allow fetching channels * Refactor and add reaction add partials * Reaction remove partials * Check for emoji first * fix message fetching janky * User partials in audit logs * refactor overwrite code * guild member partials * partials as a whitelist * document GuildMember#fetch * fix: check whether a structure is a partial, not whether cache is true * typings: Updated for latest commit (#3075) * partials: fix messageUpdate behaviour (now "old" message can be partial) * partials: add warnings and docs * partials: add partials to index.yml * partials: tighten "partial" definitions * partials: fix embed-only messages counting as partials
This commit is contained in:
@@ -164,42 +164,6 @@ class ClientUser extends Structures.get('User') {
|
||||
setAFK(afk) {
|
||||
return this.setPresence({ afk });
|
||||
}
|
||||
|
||||
/**
|
||||
* An object containing either a user or access token, and an optional nickname.
|
||||
* @typedef {Object} GroupDMRecipientOptions
|
||||
* @property {UserResolvable} [user] User to add to the Group DM
|
||||
* @property {string} [accessToken] Access token to use to add a user to the Group DM
|
||||
* (only available if a bot is creating the DM)
|
||||
* @property {string} [nick] Permanent nickname (only available if a bot is creating the DM)
|
||||
* @property {string} [id] If no user resolvable is provided and you want to assign nicknames
|
||||
* you must provide user ids instead
|
||||
*/
|
||||
|
||||
/**
|
||||
* Creates a Group DM.
|
||||
* @param {GroupDMRecipientOptions[]} recipients The recipients
|
||||
* @returns {Promise<GroupDMChannel>}
|
||||
* @example
|
||||
* // Create a Group DM with a token provided from OAuth
|
||||
* client.user.createGroupDM([{
|
||||
* user: '66564597481480192',
|
||||
* accessToken: token
|
||||
* }])
|
||||
* .then(console.log)
|
||||
* .catch(console.error);
|
||||
*/
|
||||
createGroupDM(recipients) {
|
||||
const data = this.bot ? {
|
||||
access_tokens: recipients.map(u => u.accessToken),
|
||||
nicks: recipients.reduce((o, r) => {
|
||||
if (r.nick) o[r.user ? r.user.id : r.id] = r.nick;
|
||||
return o;
|
||||
}, {}),
|
||||
} : { recipients: recipients.map(u => this.client.users.resolveID(u.user || u.id)) };
|
||||
return this.client.api.users('@me').channels.post({ data })
|
||||
.then(res => this.client.channels.add(res));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = ClientUser;
|
||||
|
||||
Reference in New Issue
Block a user