mirror of
https://github.com/discordjs/discord.js.git
synced 2026-03-17 12:03:31 +01:00
fix(Actions): inject built data by using a symbol (#9204)
This commit is contained in:
@@ -34,7 +34,7 @@ class GenericAction {
|
|||||||
getChannel(data) {
|
getChannel(data) {
|
||||||
const id = data.channel_id ?? data.id;
|
const id = data.channel_id ?? data.id;
|
||||||
return (
|
return (
|
||||||
data.channel ??
|
data[this.client.actions.injectedChannel] ??
|
||||||
this.getPayload(
|
this.getPayload(
|
||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
@@ -51,7 +51,7 @@ class GenericAction {
|
|||||||
getMessage(data, channel, cache) {
|
getMessage(data, channel, cache) {
|
||||||
const id = data.message_id ?? data.id;
|
const id = data.message_id ?? data.id;
|
||||||
return (
|
return (
|
||||||
data.message ??
|
data[this.client.actions.injectedMessage] ??
|
||||||
this.getPayload(
|
this.getPayload(
|
||||||
{
|
{
|
||||||
id,
|
id,
|
||||||
@@ -86,7 +86,7 @@ class GenericAction {
|
|||||||
|
|
||||||
getUser(data) {
|
getUser(data) {
|
||||||
const id = data.user_id;
|
const id = data.user_id;
|
||||||
return data.user ?? this.getPayload({ id }, this.client.users, id, PartialTypes.USER);
|
return data[this.client.actions.injectedUser] ?? this.getPayload({ id }, this.client.users, id, PartialTypes.USER);
|
||||||
}
|
}
|
||||||
|
|
||||||
getUserFromMember(data) {
|
getUserFromMember(data) {
|
||||||
|
|||||||
@@ -4,6 +4,13 @@ class ActionsManager {
|
|||||||
constructor(client) {
|
constructor(client) {
|
||||||
this.client = client;
|
this.client = client;
|
||||||
|
|
||||||
|
// These symbols represent fully built data that we inject at times when calling actions manually. Action#getUser,
|
||||||
|
// for example, will return the injected data (which is assumed to be a built structure) instead of trying to make
|
||||||
|
// it from provided data
|
||||||
|
this.injectedUser = Symbol('djs.actions.injectedUser');
|
||||||
|
this.injectedChannel = Symbol('djs.actions.injectedChannel');
|
||||||
|
this.injectedMessage = Symbol('djs.actions.injectedMessage');
|
||||||
|
|
||||||
this.register(require('./ApplicationCommandPermissionsUpdate'));
|
this.register(require('./ApplicationCommandPermissionsUpdate'));
|
||||||
this.register(require('./AutoModerationActionExecution'));
|
this.register(require('./AutoModerationActionExecution'));
|
||||||
this.register(require('./AutoModerationRuleCreate'));
|
this.register(require('./AutoModerationRuleCreate'));
|
||||||
|
|||||||
@@ -802,9 +802,9 @@ class Message extends Base {
|
|||||||
|
|
||||||
return this.client.actions.MessageReactionAdd.handle(
|
return this.client.actions.MessageReactionAdd.handle(
|
||||||
{
|
{
|
||||||
user: this.client.user,
|
[this.client.actions.injectedUser]: this.client.user,
|
||||||
channel: this.channel,
|
[this.client.actions.injectedChannel]: this.channel,
|
||||||
message: this,
|
[this.client.actions.injectedMessage]: this,
|
||||||
emoji: Util.resolvePartialEmoji(emoji),
|
emoji: Util.resolvePartialEmoji(emoji),
|
||||||
},
|
},
|
||||||
true,
|
true,
|
||||||
|
|||||||
Reference in New Issue
Block a user