fix: add user object on interaction and interaction_metadata for messages
This commit is contained in:
parent
4b5db1c2f4
commit
a94f84dd72
@ -229,17 +229,25 @@ router.get(
|
||||
return x;
|
||||
});
|
||||
|
||||
await ret
|
||||
.filter((x) => x.interaction_metadata && !x.interaction_metadata.user)
|
||||
.forEachAsync(async (x) => {
|
||||
x.interaction_metadata!.user = await User.findOne({ where: { id: x.interaction_metadata!.user_id } });
|
||||
x.interaction!.user = await User.findOne({ where: { id: x.interaction_metadata!.user_id } });
|
||||
});
|
||||
|
||||
// polyfill message references for old messages
|
||||
await ret.filter((msg) => msg.message_reference && !msg.referenced_message?.id).forEachAsync(async (msg) => {
|
||||
const whereOptions: { id: string; guild_id?: string; channel_id?: string } = {
|
||||
id: msg.message_reference!.message_id,
|
||||
};
|
||||
if (msg.message_reference!.guild_id) whereOptions.guild_id = msg.message_reference!.guild_id;
|
||||
if (msg.message_reference!.channel_id) whereOptions.channel_id = msg.message_reference!.channel_id;
|
||||
await ret
|
||||
.filter((msg) => msg.message_reference && !msg.referenced_message?.id)
|
||||
.forEachAsync(async (msg) => {
|
||||
const whereOptions: { id: string; guild_id?: string; channel_id?: string } = {
|
||||
id: msg.message_reference!.message_id,
|
||||
};
|
||||
if (msg.message_reference!.guild_id) whereOptions.guild_id = msg.message_reference!.guild_id;
|
||||
if (msg.message_reference!.channel_id) whereOptions.channel_id = msg.message_reference!.channel_id;
|
||||
|
||||
msg.referenced_message = await Message.findOne({ where: whereOptions, relations: ["author", "mentions", "mention_roles", "mention_channels"] });
|
||||
});
|
||||
msg.referenced_message = await Message.findOne({ where: whereOptions, relations: ["author", "mentions", "mention_roles", "mention_channels"] });
|
||||
});
|
||||
|
||||
return res.json(ret);
|
||||
},
|
||||
|
||||
@ -174,6 +174,7 @@ export class Message extends BaseClass {
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
interaction?: {
|
||||
user: User | null;
|
||||
id: string;
|
||||
type: InteractionType;
|
||||
name: string;
|
||||
@ -181,6 +182,7 @@ export class Message extends BaseClass {
|
||||
|
||||
@Column({ type: "simple-json", nullable: true })
|
||||
interaction_metadata?: {
|
||||
user: User | null;
|
||||
id: string;
|
||||
type: InteractionType;
|
||||
user_id: string;
|
||||
|
||||
Reference in New Issue
Block a user