some abaddon compat

This commit is contained in:
Madeline 2023-07-31 21:00:03 +10:00
parent 45e7d763cf
commit 496cfc8ea1
No known key found for this signature in database
GPG Key ID: 80D25DA3BCB24281
3 changed files with 63 additions and 35 deletions

View File

@ -144,8 +144,9 @@ router.get(
const endpoint = Config.get().cdn.endpointPublic; const endpoint = Config.get().cdn.endpointPublic;
return res.json( const ret = messages.map((x: Message) => {
messages.map((x: Partial<Message>) => { x = x.toJSON();
(x.reactions || []).forEach((y: Partial<Reaction>) => { (x.reactions || []).forEach((y: Partial<Reaction>) => {
// eslint-disable-next-line @typescript-eslint/ban-ts-comment // eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore //@ts-ignore
@ -180,8 +181,9 @@ router.get(
// } // }
return x; return x;
}), });
);
return res.json(ret);
}, },
); );
@ -307,9 +309,11 @@ router.post(
embeds, embeds,
channel_id, channel_id,
attachments, attachments,
edited_timestamp: undefined,
timestamp: new Date(), timestamp: new Date(),
}); });
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
//@ts-ignore dont care2
message.edited_timestamp = null;
channel.last_message_id = message.id; channel.last_message_id = message.id;

View File

@ -193,7 +193,7 @@ export class Message extends BaseClass {
}; };
@Column({ nullable: true }) @Column({ nullable: true })
flags?: string; flags?: number;
@Column({ type: "simple-json", nullable: true }) @Column({ type: "simple-json", nullable: true })
message_reference?: { message_reference?: {
@ -217,6 +217,30 @@ export class Message extends BaseClass {
@Column({ type: "simple-json", nullable: true }) @Column({ type: "simple-json", nullable: true })
components?: MessageComponent[]; components?: MessageComponent[];
toJSON(): Message {
return {
...this,
author_id: undefined,
member_id: undefined,
guild_id: undefined,
webhook_id: undefined,
application_id: undefined,
nonce: undefined,
tts: this.tts ?? false,
guild: this.guild ?? undefined,
webhook: this.webhook ?? undefined,
interaction: this.interaction ?? undefined,
reactions: this.reactions ?? undefined,
sticker_items: this.sticker_items ?? undefined,
message_reference: this.message_reference ?? undefined,
author: this.author?.toPublicUser() ?? undefined,
activity: this.activity ?? undefined,
application: this.application ?? undefined,
components: this.components ?? undefined,
};
}
} }
export interface MessageComponent { export interface MessageComponent {

View File

@ -29,7 +29,7 @@ export interface MessageCreateSchema {
nonce?: string; nonce?: string;
channel_id?: string; channel_id?: string;
tts?: boolean; tts?: boolean;
flags?: string; flags?: number;
embeds?: Embed[]; embeds?: Embed[];
embed?: Embed; embed?: Embed;
// TODO: ^ embed is deprecated in favor of embeds (https://discord.com/developers/docs/resources/channel#message-object) // TODO: ^ embed is deprecated in favor of embeds (https://discord.com/developers/docs/resources/channel#message-object)