fix: add user object on interaction and interaction_metadata for messages

This commit is contained in:
CyberL1 2025-10-17 22:20:51 +02:00 committed by Rory&
parent 4b5db1c2f4
commit a94f84dd72
2 changed files with 18 additions and 8 deletions

View File

@ -229,9 +229,17 @@ router.get(
return x; 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 // polyfill message references for old messages
await ret.filter((msg) => msg.message_reference && !msg.referenced_message?.id).forEachAsync(async (msg) => { await ret
.filter((msg) => msg.message_reference && !msg.referenced_message?.id)
.forEachAsync(async (msg) => {
const whereOptions: { id: string; guild_id?: string; channel_id?: string } = { const whereOptions: { id: string; guild_id?: string; channel_id?: string } = {
id: msg.message_reference!.message_id, id: msg.message_reference!.message_id,
}; };

View File

@ -174,6 +174,7 @@ export class Message extends BaseClass {
@Column({ type: "simple-json", nullable: true }) @Column({ type: "simple-json", nullable: true })
interaction?: { interaction?: {
user: User | null;
id: string; id: string;
type: InteractionType; type: InteractionType;
name: string; name: string;
@ -181,6 +182,7 @@ export class Message extends BaseClass {
@Column({ type: "simple-json", nullable: true }) @Column({ type: "simple-json", nullable: true })
interaction_metadata?: { interaction_metadata?: {
user: User | null;
id: string; id: string;
type: InteractionType; type: InteractionType;
user_id: string; user_id: string;