mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-05-10 12:25:02 +00:00
Pre-plugin moves
This commit is contained in:
parent
9fc045cd38
commit
8f7a6510eb
13 changed files with 62 additions and 52 deletions
|
@ -2,11 +2,11 @@ import { getRepository, Repository } from "typeorm";
|
|||
import { BaseGuildRepository } from "./BaseGuildRepository";
|
||||
import { ISavedMessageData, SavedMessage } from "./entities/SavedMessage";
|
||||
import { QueuedEventEmitter } from "../QueuedEventEmitter";
|
||||
import { GuildChannel, Message, PossiblyUncachedTextableChannel } from "eris";
|
||||
import moment from "moment-timezone";
|
||||
import { MINUTES, SECONDS } from "../utils";
|
||||
import { isAPI } from "../globals";
|
||||
import { cleanupMessages } from "./cleanup/messages";
|
||||
import { GuildChannel, Message } from "discord.js";
|
||||
|
||||
if (!isAPI()) {
|
||||
const CLEANUP_INTERVAL = 5 * MINUTES;
|
||||
|
@ -34,19 +34,19 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
this.toBePermanent = new Set();
|
||||
}
|
||||
|
||||
public msgToSavedMessageData(msg: Message<PossiblyUncachedTextableChannel>): ISavedMessageData {
|
||||
public msgToSavedMessageData(msg: Message): ISavedMessageData {
|
||||
const data: ISavedMessageData = {
|
||||
author: {
|
||||
username: msg.author.username,
|
||||
discriminator: msg.author.discriminator,
|
||||
},
|
||||
content: msg.content,
|
||||
timestamp: msg.timestamp,
|
||||
timestamp: msg.createdTimestamp,
|
||||
};
|
||||
|
||||
if (msg.attachments.length) data.attachments = msg.attachments;
|
||||
if (msg.attachments.size) data.attachments = msg.attachments.array();
|
||||
if (msg.embeds.length) data.embeds = msg.embeds;
|
||||
if (msg.stickers?.length) data.stickers = msg.stickers;
|
||||
if (msg.stickers?.size) data.stickers = msg.stickers.array();
|
||||
|
||||
return data;
|
||||
}
|
||||
|
@ -139,12 +139,12 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
this.events.emit(`create:${data.id}`, [inserted]);
|
||||
}
|
||||
|
||||
async createFromMsg(msg: Message<PossiblyUncachedTextableChannel>, overrides = {}) {
|
||||
async createFromMsg(msg: Message, overrides = {}) {
|
||||
const existingSavedMsg = await this.find(msg.id);
|
||||
if (existingSavedMsg) return;
|
||||
|
||||
const savedMessageData = this.msgToSavedMessageData(msg);
|
||||
const postedAt = moment.utc(msg.timestamp, "x").format("YYYY-MM-DD HH:mm:ss");
|
||||
const postedAt = moment.utc(msg.createdTimestamp, "x").format("YYYY-MM-DD HH:mm:ss");
|
||||
|
||||
const data = {
|
||||
id: msg.id,
|
||||
|
@ -222,7 +222,7 @@ export class GuildSavedMessages extends BaseGuildRepository {
|
|||
this.events.emit(`update:${id}`, [newMessage, oldMessage]);
|
||||
}
|
||||
|
||||
async saveEditFromMsg(msg: Message<PossiblyUncachedTextableChannel>) {
|
||||
async saveEditFromMsg(msg: Message) {
|
||||
const newData = this.msgToSavedMessageData(msg);
|
||||
return this.saveEdit(msg.id, newData);
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue