mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-15 05:41:51 +00:00
GuildSavedMessages: save messages in a more compact way
This commit is contained in:
parent
cfc36be127
commit
01d73565b6
2 changed files with 9 additions and 6 deletions
|
@ -23,15 +23,18 @@ export class GuildSavedMessages extends BaseRepository {
|
|||
}
|
||||
|
||||
public msgToSavedMessageData(msg: Message): ISavedMessageData {
|
||||
return {
|
||||
attachments: msg.attachments,
|
||||
const data: ISavedMessageData = {
|
||||
author: {
|
||||
username: msg.author.username,
|
||||
discriminator: msg.author.discriminator
|
||||
},
|
||||
content: msg.content,
|
||||
embeds: msg.embeds
|
||||
content: msg.content
|
||||
};
|
||||
|
||||
if (msg.attachments.length) data.attachments = msg.attachments;
|
||||
if (msg.embeds.length) data.embeds = msg.embeds;
|
||||
|
||||
return data;
|
||||
}
|
||||
|
||||
async cleanup() {
|
||||
|
|
|
@ -2,13 +2,13 @@ import { Entity, Column, PrimaryColumn } from "typeorm";
|
|||
import { Message } from "eris";
|
||||
|
||||
export interface ISavedMessageData {
|
||||
attachments: object[];
|
||||
attachments?: object[];
|
||||
author: {
|
||||
username: string;
|
||||
discriminator: string;
|
||||
};
|
||||
content: string;
|
||||
embeds: object[];
|
||||
embeds?: object[];
|
||||
}
|
||||
|
||||
@Entity("messages")
|
||||
|
|
Loading…
Add table
Reference in a new issue