Files
illegitimate-bot/src/events/server/messages/snipecache.ts

36 lines
1.0 KiB
TypeScript

import { ChannelType, Message } from "discord.js"
import { IEvent } from "interfaces"
import snipeCacheSchema from "schemas/snipeCacheSchema"
import mongoose from "mongoose"
import { SnipeCache } from "typings"
export = {
name: "snipecache",
description: "Logs messages for the snipe command",
event: "messageDelete",
disabled: true,
async execute(message: Message) {
if (message.channel.type !== ChannelType.GuildText) return
if (message.author.bot) return
const msg: SnipeCache = {
author: message.author.id,
content: message.content,
channel: message.channel.id,
createdAt: message.createdTimestamp,
deletedAt: Date.now(),
attachments: message.attachments.map(a => a.url) || []
}
const snipeCache = new snipeCacheSchema({
_id: new mongoose.Types.ObjectId(),
userid: message.author.id,
channelid: message.channel.id,
data: msg
})
await snipeCache.save()
}
} as IEvent