3
0
Fork 0
mirror of https://github.com/ZeppelinBot/Zeppelin.git synced 2025-05-10 12:25:02 +00:00

More rework progress, mostly done up to ModActions

This commit is contained in:
Dark 2021-06-01 04:33:02 +02:00
parent 52839cc9f3
commit 57893e7f76
No known key found for this signature in database
GPG key ID: 2CD6ACB6B0A87B8A
38 changed files with 199 additions and 241 deletions

View file

@ -14,7 +14,7 @@ export const SaveMessagesToDBCmd = messageSaverCmd({
},
async run({ message: msg, args, pluginData }) {
await msg.channel.createMessage("Saving specified messages...");
await msg.channel.send("Saving specified messages...");
const { savedCount, failed } = await saveMessagesToDB(pluginData, args.channel, args.ids.trim().split(" "));
if (failed.length) {

View file

@ -13,13 +13,13 @@ export const SavePinsToDBCmd = messageSaverCmd({
},
async run({ message: msg, args, pluginData }) {
await msg.channel.createMessage(`Saving pins from <#${args.channel.id}>...`);
await msg.channel.send(`Saving pins from <#${args.channel.id}>...`);
const pins = await args.channel.getPins();
const pins = await args.channel.messages.fetchPinned();
const { savedCount, failed } = await saveMessagesToDB(
pluginData,
args.channel,
pins.map(m => m.id),
pins.keyArray(),
);
if (failed.length) {

View file

@ -1,3 +1,4 @@
import { Message } from "discord.js";
import { messageSaverEvt } from "../types";
export const MessageCreateEvt = messageSaverEvt({
@ -7,7 +8,7 @@ export const MessageCreateEvt = messageSaverEvt({
async listener(meta) {
// Only save regular chat messages
if (meta.args.message.type !== 0) {
if (meta.args.message.type !== "DEFAULT" && meta.args.message.type !== "REPLY") {
return;
}
@ -21,11 +22,11 @@ export const MessageUpdateEvt = messageSaverEvt({
allowSelf: true,
async listener(meta) {
if (meta.args.message.type !== 0) {
if (meta.args.newMessage.type !== "DEFAULT" && meta.args.newMessage.type !== "REPLY") {
return;
}
await meta.pluginData.state.savedMessages.saveEditFromMsg(meta.args.message);
await meta.pluginData.state.savedMessages.saveEditFromMsg(meta.args.newMessage as Message);
},
});
@ -36,7 +37,7 @@ export const MessageDeleteEvt = messageSaverEvt({
async listener(meta) {
const msg = meta.args.message as Message;
if (msg.type != null && msg.type !== 0) {
if (msg.type != null && meta.args.message.type !== "DEFAULT" && meta.args.message.type !== "REPLY") {
return;
}

View file

@ -1,5 +1,6 @@
import { MessageSaverPluginType } from "./types";
import { GuildPluginData } from "knub";
import { TextChannel, Message } from "discord.js";
export async function saveMessagesToDB(
pluginData: GuildPluginData<MessageSaverPluginType>,
@ -14,7 +15,7 @@ export async function saveMessagesToDB(
let thisMsg: Message;
try {
thisMsg = await channel.getMessage(id);
thisMsg = await channel.messages.fetch(id);
if (!thisMsg) {
failed.push(id);