Merge branch 'dev' into 'main'
Dev See merge request illegitimate/illegitimate-bot!236
This commit is contained in:
@@ -1,74 +0,0 @@
|
|||||||
import { GuildMember, SlashCommandBuilder } from "discord.js"
|
|
||||||
import snipeCacheSchema from "schemas/snipeCacheSchema"
|
|
||||||
import { ICommand } from "interfaces"
|
|
||||||
import { embedColor } from "config/options"
|
|
||||||
import { SnipeCache } from "typings"
|
|
||||||
|
|
||||||
export = {
|
|
||||||
name: "snipe",
|
|
||||||
description: "Snipes the last deleted message of a user",
|
|
||||||
public: true,
|
|
||||||
dev: false,
|
|
||||||
|
|
||||||
data: new SlashCommandBuilder()
|
|
||||||
.setName("snipe")
|
|
||||||
.setDescription("Snipes the last deleted message of a user")
|
|
||||||
.addUserOption(option =>
|
|
||||||
option
|
|
||||||
.setName("user")
|
|
||||||
.setDescription("The user to snipe")
|
|
||||||
.setRequired(true)
|
|
||||||
)
|
|
||||||
.setDMPermission(false),
|
|
||||||
|
|
||||||
async execute(interaction) {
|
|
||||||
await interaction.deferReply()
|
|
||||||
const member = interaction.options.getMember("user") as GuildMember
|
|
||||||
const snipeCache = await snipeCacheSchema.find({
|
|
||||||
userid: member.user.id,
|
|
||||||
channelid: interaction.channel!.id
|
|
||||||
})
|
|
||||||
const messages: string[] = []
|
|
||||||
|
|
||||||
if (!snipeCache.length) {
|
|
||||||
await interaction.editReply({
|
|
||||||
embeds: [{
|
|
||||||
description: "No messages to snipe",
|
|
||||||
color: embedColor
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
return
|
|
||||||
}
|
|
||||||
|
|
||||||
let i = 1
|
|
||||||
for (const msg of snipeCache) {
|
|
||||||
const data: SnipeCache = msg.data
|
|
||||||
if (!data.attachments.length) {
|
|
||||||
messages.push(`**Message #${i}:** ${data.content}\n`)
|
|
||||||
} else {
|
|
||||||
messages.push(`**Message #${i}:** ${data.content}`)
|
|
||||||
messages.push(`**Attachments:** ${data.attachments.join(", ")}\n`)
|
|
||||||
}
|
|
||||||
i++
|
|
||||||
}
|
|
||||||
|
|
||||||
await interaction.editReply({
|
|
||||||
embeds: [{
|
|
||||||
author: {
|
|
||||||
name: member.user.username,
|
|
||||||
icon_url: member.user.avatarURL() || undefined
|
|
||||||
},
|
|
||||||
description: messages.join("\n"),
|
|
||||||
thumbnail: {
|
|
||||||
url: member.user.avatarURL() || ""
|
|
||||||
},
|
|
||||||
color: embedColor,
|
|
||||||
footer: {
|
|
||||||
text: "ID: " + member.user.id,
|
|
||||||
icon_url: interaction.guild!.iconURL() || undefined
|
|
||||||
},
|
|
||||||
timestamp: new Date().toISOString()
|
|
||||||
}]
|
|
||||||
})
|
|
||||||
}
|
|
||||||
} as ICommand
|
|
||||||
@@ -1,35 +0,0 @@
|
|||||||
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
|
|
||||||
@@ -1,11 +0,0 @@
|
|||||||
import { model, Schema } from "mongoose"
|
|
||||||
|
|
||||||
const snipeCacheSchema = new Schema({
|
|
||||||
_id: Schema.Types.ObjectId,
|
|
||||||
userid: { type: String, required: true },
|
|
||||||
channelid: { type: String, required: true },
|
|
||||||
data: { type: Object, required: true },
|
|
||||||
date: { type: Date, default: Date.now(), expires: 600 }
|
|
||||||
})
|
|
||||||
|
|
||||||
export default model("snipeCache", snipeCacheSchema, "snipeCache")
|
|
||||||
Reference in New Issue
Block a user