forked from Galactic/modmail
reminder message tweaks
This commit is contained in:
parent
02099caa35
commit
b04bbfa574
@ -11,10 +11,13 @@ class Cache {
|
||||
this.saveInterval = opts.saveInterval;
|
||||
this._ready = false;
|
||||
|
||||
// Data that gets stored to persistent cache
|
||||
this.queue = [];
|
||||
this.channels = {};
|
||||
this.lastActivity = {};
|
||||
this.misc = {}; // Random misc data, should not be non-primitive data types
|
||||
|
||||
// Stored separately if at all
|
||||
this.modmail = {};
|
||||
this.updatedThreads = [];
|
||||
|
||||
@ -91,7 +94,8 @@ class Cache {
|
||||
return {
|
||||
queue: this.queue,
|
||||
channels: this.channels,
|
||||
lastActivity: this.lastActivity
|
||||
lastActivity: this.lastActivity,
|
||||
misc: this.misc
|
||||
};
|
||||
}
|
||||
|
||||
|
@ -47,7 +47,7 @@ class ModmailClient extends Client {
|
||||
this.mainServer = this.guilds.cache.get(this._options.mainGuild);
|
||||
this.bansServer = this.guilds.cache.get(this._options.bansGuild) || null;
|
||||
this.logger.info(`Starting up modmail handler`);
|
||||
this.modmail.init();
|
||||
await this.modmail.init();
|
||||
|
||||
process.on('exit', () => {
|
||||
this.logger.warn('process exiting');
|
||||
|
@ -35,7 +35,7 @@ class Modmail {
|
||||
|
||||
}
|
||||
|
||||
init() {
|
||||
async init() {
|
||||
|
||||
this.mainServer = this.client.mainServer;
|
||||
if (!this.mainServer) throw new Error(`Missing main server`);
|
||||
@ -51,6 +51,7 @@ class Modmail {
|
||||
if (this._reminderChannel) {
|
||||
this.reminderChannel = this.client.channels.resolve(this._reminderChannel);
|
||||
this.reminder = setInterval(this.sendReminder.bind(this), this.reminderInterval * 60 * 1000);
|
||||
this.lastReminder = await this.reminderChannel.messages.fetch(this.cache.misc.lastReminder).catch(() => null);
|
||||
this.sendReminder();
|
||||
}
|
||||
|
||||
@ -374,6 +375,7 @@ class Modmail {
|
||||
await this.lastReminder.delete();
|
||||
}
|
||||
this.lastReminder = await channel.send(str);
|
||||
this.cache.lastReminder = this.lastReminder.id;
|
||||
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user