mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-13 01:53: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:
@@ -1,5 +1,7 @@
|
||||
'use strict';
|
||||
|
||||
const { PartialTypes } = require('../../util/Constants');
|
||||
|
||||
/*
|
||||
|
||||
ABOUT ACTIONS
|
||||
@@ -20,6 +22,27 @@ class GenericAction {
|
||||
handle(data) {
|
||||
return data;
|
||||
}
|
||||
|
||||
getChannel(data) {
|
||||
const id = data.channel_id || data.id;
|
||||
return data.channel || (this.client.options.partials.includes(PartialTypes.CHANNEL) ?
|
||||
this.client.channels.add({
|
||||
id,
|
||||
guild_id: data.guild_id,
|
||||
}) :
|
||||
this.client.channels.get(id));
|
||||
}
|
||||
|
||||
getMessage(data, channel) {
|
||||
const id = data.message_id || data.id;
|
||||
return data.message || (this.client.options.partials.includes(PartialTypes.MESSAGE) ?
|
||||
channel.messages.add({
|
||||
id,
|
||||
channel_id: channel.id,
|
||||
guild_id: data.guild_id || (channel.guild ? channel.guild.id : null),
|
||||
}) :
|
||||
channel.messages.get(id));
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = GenericAction;
|
||||
|
||||
Reference in New Issue
Block a user