mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Fix bulk message deletion logging. Remove !clean command and response after a short delay.
This commit is contained in:
parent
a93f25d638
commit
9687359105
2 changed files with 25 additions and 5 deletions
|
@ -186,10 +186,12 @@ export class GuildSavedMessages extends BaseRepository {
|
||||||
.andWhere("id IN (:ids)", { ids })
|
.andWhere("id IN (:ids)", { ids })
|
||||||
.execute();
|
.execute();
|
||||||
|
|
||||||
return this.messages
|
const deleted = await this.messages
|
||||||
.createQueryBuilder()
|
.createQueryBuilder()
|
||||||
.where("id IN (:ids)", { ids })
|
.where("id IN (:ids)", { ids })
|
||||||
.getMany();
|
.getMany();
|
||||||
|
|
||||||
|
this.events.emit("deleteBulk", [deleted]);
|
||||||
}
|
}
|
||||||
|
|
||||||
async saveEdit(id, newData: ISavedMessageData) {
|
async saveEdit(id, newData: ISavedMessageData) {
|
||||||
|
|
|
@ -13,6 +13,7 @@ import { GuildArchives } from "../data/GuildArchives";
|
||||||
|
|
||||||
const MAX_SEARCH_RESULTS = 15;
|
const MAX_SEARCH_RESULTS = 15;
|
||||||
const MAX_CLEAN_COUNT = 50;
|
const MAX_CLEAN_COUNT = 50;
|
||||||
|
const CLEAN_COMMAND_DELETE_DELAY = 5000;
|
||||||
|
|
||||||
const activeReloads: Map<string, TextChannel> = new Map();
|
const activeReloads: Map<string, TextChannel> = new Map();
|
||||||
|
|
||||||
|
@ -136,7 +137,9 @@ export class UtilityPlugin extends Plugin {
|
||||||
this.logs.ignoreLog(LogType.MESSAGE_DELETE, savedMessages[0].id);
|
this.logs.ignoreLog(LogType.MESSAGE_DELETE, savedMessages[0].id);
|
||||||
this.logs.ignoreLog(LogType.MESSAGE_DELETE_BULK, savedMessages[0].id);
|
this.logs.ignoreLog(LogType.MESSAGE_DELETE_BULK, savedMessages[0].id);
|
||||||
|
|
||||||
await this.bot.deleteMessages(channel.id, savedMessages.map(m => m.id));
|
const idsToDelete = savedMessages.map(m => m.id);
|
||||||
|
await this.bot.deleteMessages(channel.id, idsToDelete);
|
||||||
|
await this.savedMessages.markBulkAsDeleted(idsToDelete);
|
||||||
|
|
||||||
savedMessages.reverse();
|
savedMessages.reverse();
|
||||||
const user = this.bot.users.get(savedMessages[0].user_id);
|
const user = this.bot.users.get(savedMessages[0].user_id);
|
||||||
|
@ -165,9 +168,14 @@ export class UtilityPlugin extends Plugin {
|
||||||
await this.cleanMessages(msg.channel, messagesToClean, msg.author);
|
await this.cleanMessages(msg.channel, messagesToClean, msg.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.channel.createMessage(
|
const responseMsg = await msg.channel.createMessage(
|
||||||
successMessage(`Cleaned ${messagesToClean.length} ${messagesToClean.length === 1 ? "message" : "messages"}`)
|
successMessage(`Cleaned ${messagesToClean.length} ${messagesToClean.length === 1 ? "message" : "messages"}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
msg.delete().catch(() => {});
|
||||||
|
responseMsg.delete().catch(() => {});
|
||||||
|
}, CLEAN_COMMAND_DELETE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@d.command("clean user", "<userId:string> <count:number>")
|
@d.command("clean user", "<userId:string> <count:number>")
|
||||||
|
@ -183,9 +191,14 @@ export class UtilityPlugin extends Plugin {
|
||||||
await this.cleanMessages(msg.channel, messagesToClean, msg.author);
|
await this.cleanMessages(msg.channel, messagesToClean, msg.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.channel.createMessage(
|
const responseMsg = await msg.channel.createMessage(
|
||||||
successMessage(`Cleaned ${messagesToClean.length} ${messagesToClean.length === 1 ? "message" : "messages"}`)
|
successMessage(`Cleaned ${messagesToClean.length} ${messagesToClean.length === 1 ? "message" : "messages"}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
msg.delete().catch(() => {});
|
||||||
|
responseMsg.delete().catch(() => {});
|
||||||
|
}, CLEAN_COMMAND_DELETE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@d.command("clean bot", "<count:number>")
|
@d.command("clean bot", "<count:number>")
|
||||||
|
@ -201,9 +214,14 @@ export class UtilityPlugin extends Plugin {
|
||||||
await this.cleanMessages(msg.channel, messagesToClean, msg.author);
|
await this.cleanMessages(msg.channel, messagesToClean, msg.author);
|
||||||
}
|
}
|
||||||
|
|
||||||
msg.channel.createMessage(
|
const responseMsg = await msg.channel.createMessage(
|
||||||
successMessage(`Cleaned ${messagesToClean.length} ${messagesToClean.length === 1 ? "message" : "messages"}`)
|
successMessage(`Cleaned ${messagesToClean.length} ${messagesToClean.length === 1 ? "message" : "messages"}`)
|
||||||
);
|
);
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
msg.delete().catch(() => {});
|
||||||
|
responseMsg.delete().catch(() => {});
|
||||||
|
}, CLEAN_COMMAND_DELETE_DELAY);
|
||||||
}
|
}
|
||||||
|
|
||||||
@d.command("info", "<userId:userId>")
|
@d.command("info", "<userId:userId>")
|
||||||
|
|
Loading…
Add table
Reference in a new issue