holy fuck what a bug

This commit is contained in:
Erik 2021-06-20 01:21:27 +03:00
parent cee1f487d5
commit e0786f0fbd
No known key found for this signature in database
GPG Key ID: 7E862371D3409F16
2 changed files with 16 additions and 9 deletions

View File

@ -57,12 +57,12 @@ class ModmailClient extends Client {
this.modmail.init();
process.on('exit', () => {
this.logger.warn('process exiting');
this.saveCache();
this.modmail.saveHistory();
// eslint-disable-next-line no-process-exit
process.exit();
});
process.on('SIGINT', () => {
this.logger.warn('received sigint');
this.saveCache.bind(this);
this.modmail.saveHistory();
// eslint-disable-next-line no-process-exit
@ -96,7 +96,12 @@ class ModmailClient extends Client {
if (message.author.bot) return;
// No command handling in dms, at least for now
if (!message.guild) return this.modmail.handleUser(message);
if (!message.guild) try {
return this.modmail.handleUser(message);
} catch (err) {
this.logger.error(`Error during user handle:\n${err.stack}`);
return;
}
const { prefix } = this;
const { channel, guild, content, member } = message;

View File

@ -194,7 +194,7 @@ class Modmail {
if (this.awaitingChannel[member.id]) return this.awaitingChannel[member.id];
// eslint-disable-next-line no-async-promise-executor
const promise = new Promise(async (resolve) => {
const promise = new Promise(async (resolve, reject) => {
const channelID = this.client.cache.channels[member.id];
const guild = this.mainServer;
@ -245,19 +245,21 @@ class Modmail {
continue;
}
const mem = entry.author.id === member.id ? member : this.mainServer.members.resolve(entry.author);
const user = await this.client.resolveUser(entry.author).catch(this.client.logger.error.bind(this.client.logger));
const mem = await this.getMember(user.id).catch(this.client.logger.error.bind(this.client.logger));
if (!user) return reject(new Error(`Failed to find user`));
const embed = {
footer: {
text: mem.id
text: user.id
},
author: {
name: mem.user.tag + (entry.anon ? ' (ANONYMOUS REPLY)' : ''),
name: user.tag + (entry.anon ? ' (ANONYMOUS REPLY)' : ''),
// eslint-disable-next-line camelcase
icon_url: mem.user.displayAvatarURL({ dynamic: true })
icon_url: user.displayAvatarURL({ dynamic: true })
},
description: entry.content,
color: mem.highestRoleColor,
color: mem?.highestRoleColor || 0,
fields: [],
timestamp: new Date(entry.timestamp)
};