bugfix to channel sweeping

This commit is contained in:
Erik 2021-06-19 22:09:36 +03:00
parent d0dd677294
commit 916401de89
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
3 changed files with 20 additions and 20 deletions

View File

@ -264,23 +264,6 @@ class Modmail {
}
async overflow() { // Overflows new modmail category into read
const channels = this.newMail.children.sort((a, b) => {
if (!a.lastMessage) return -1;
if (!b.lastMessage) return 1;
return a.lastMessage.createdTimestamp - b.lastMessage.createdTimestamp;
}).array();
if (this.readMail.children.size >= 45) await this.sweepChannels({ count: 5, force: true });
let counter = 0;
for (const channel of channels) {
await channel.edit({ parentID: this.readMail.id });
counter++;
if (counter === 5) break;
}
}
async sendCannedResponse({ message, responseName, anon }) {
const content = this.getCanned(responseName);
@ -446,7 +429,7 @@ class Modmail {
this.client.logger.info(`Swept ${channelCount} channels from graveyard, cleaning up answered...`);
const answered = this.readMail.children
.filter((channel) => !channel.lastMessage || channel.answered && channel.lastMessage.createdTimestamp < Date.now() - 15 * 60 * 1000 || force)
.filter((channel) => !channel.lastMessage || channel.lastMessage.createdTimestamp < Date.now() - 15 * 60 * 1000 || force)
.sort((a, b) => {
if (!a.lastMessage) return -1;
if (!b.lastMessage) return 1;
@ -466,6 +449,23 @@ class Modmail {
}
async overflow() { // Overflows new modmail category into read
const channels = this.newMail.children.sort((a, b) => {
if (!a.lastMessage) return -1;
if (!b.lastMessage) return 1;
return a.lastMessage.createdTimestamp - b.lastMessage.createdTimestamp;
}).array();
if (this.readMail.children.size >= 45) await this.sweepChannels({ count: 5, force: true });
let counter = 0;
for (const channel of channels) {
await channel.edit({ parentID: this.readMail.id });
counter++;
if (counter === 5) break;
}
}
async markread(message) {
const { channel, author } = message;

View File

@ -36,7 +36,7 @@ class CannedReply extends Command {
str += `**${name}:** ${content}\n`;
}
if (str.length) await channel.send(str).catch(this.client.logger.error.bind(this.client.logger));
return;
return '**__None__**';
}
return this.client.modmail.sendCannedResponse({ message, responseName: content.trim(), anon });

View File

@ -26,7 +26,7 @@ class Logs extends Command {
const { member, channel } = message;
const history = await this.client.modmail.loadHistory(user.id);
const page = this.paginate([...history].reverse(), pageNr, 10);
const page = this.paginate([...history].filter((e) => !e.markread).reverse(), pageNr, 10);
const embed = {
author: {