This commit is contained in:
Erik 2021-06-10 17:56:16 +03:00
commit 51717cf7ef
9 changed files with 25 additions and 16 deletions

View File

@ -97,7 +97,7 @@ class MuteCommand extends Command {
time = setting.defaultDuration;
}
} else {
reason = reason.slice(1).join(' ');
reason = reason.slice(1);
}
if(time !== 0) {
@ -110,7 +110,7 @@ class MuteCommand extends Command {
.handleInfraction(Mute, message, {
targets: parsed,
duration: time,
reason
reason: reason.join(' ')
});
}

View File

@ -127,7 +127,7 @@ class MessageCache extends Observer {
}
const buffer = await Util.downloadAsBuffer(attachment.proxyURL || attachment.url).catch((err) => {
this.client.logger.error(`Failed to download buffer for "${chalk.bold(data.name)}".\n${err.stack || err}`);
this.client.logger.error(`Failed to download buffer for "${chalk.bold(data.name)}".\n${err.stack || err}\nhttps://discord.com/channels/${message.guild.id}/${message.channel.id}/${message.id}`);
return null;
});
@ -140,7 +140,7 @@ class MessageCache extends Observer {
data.index = result?.insertedId;
} else {
//Upload using GridFS, not a priority right now.
this.client.logger.error(`Temporary logging; attachment "${chalk.bold(data.name)}" exceeds 15mb.`);
//this.client.logger.error(`Temporary logging; attachment "${chalk.bold(data.name)}" exceeds 15mb.`);
}
}

View File

@ -108,7 +108,7 @@ const Guild = Structures.extend('Guild', (Guild) => {
async _deleteSettings() { //Delete whole entry - remove
try {
await this.client.storageManager.guilds.deleteOne({ guildId: this.id });
await this.client.storageManager.mongodb.guilds.deleteOne({ guildId: this.id });
this._settings = { ...{}, ...this.defaultConfig }; //Create a new object so settings that change the _settings value won't replicate it towards the defaultConfig.
this._storageLog(`Database Delete (guild:${this.id}).`);
} catch(error) {

View File

@ -20,7 +20,7 @@ const GuildMember = Structures.extend('GuildMember', (GuildMember) => {
if(filtered.size > 0) return filtered.first();
const result = await this.client.storageManager.mongodb.infractions.findOne(
{ duration: 0, type, target: this.id },
{ duration: { $gt: 0 }, type, target: this.id },
{ sort: { timestamp: -1 } }// Finds latest mute.
).catch((error) => { //eslint-disable-line no-unused-vars
return null;

View File

@ -52,10 +52,10 @@ class Command extends Component {
execute() {
throw new Error(`${this.resolveable} is missing an execute function.`);
}
}
get moduleResolveable() {
return `${this.module.id}:${this.id}`;
async checkPermissions() {
//NOTE: Todo (move from permissions inhibitor)
}
usageEmbed(message, verbose = false) {
@ -108,6 +108,10 @@ class Command extends Component {
}
get moduleResolveable() {
return `${this.module.id}:${this.id}`;
}
}
module.exports = Command;

View File

@ -410,7 +410,7 @@ class ModerationManager {
await new undoClass(this.client, {
reason: `AUTO-${Constants.Opposites[i.type]} from Case ${i.case}`,
channel: guild.channels.resolve(i.channel),
hyperlink: i.logMessage && i.moderationLog ? `https://discord.com/channels/${i.guild}/${i.moderationLog}/${i.logMessage}` : null,
hyperlink: i.modLogMessage && i.modLogChannel ? `https://discord.com/channels/${i.guild}/${i.modLogChannel}/${i.modLogMessage}` : null,
data: i.data,
guild,
target,
@ -437,8 +437,8 @@ class ModerationManager {
this.client.logger.debug(`Going to resolve infraction in: ${expiration-currentDate}`);
this.callbacks.set(infraction.id, {
timeout: setTimeout(() => {
resolve(infraction);
timeout: setTimeout(async () => {
await resolve(infraction);
}, expiration-currentDate),
infraction
});

View File

@ -1,7 +1,7 @@
/* eslint-disable indent */
const { Infraction } = require('../interfaces/');
class MuteInfraction extends Infraction {
class UnmuteInfraction extends Infraction {
constructor(client, opts = {}) {
@ -45,6 +45,8 @@ class MuteInfraction extends Infraction {
removedRoles = mute.infraction.data.removedRoles; //eslint-disable-line prefer-destructuring
muteType = mute.infraction.data.muteType; //eslint-disable-line prefer-destructuring
role = mute.infraction.data.muteRole; //eslint-disable-line prefer-destructuring
} else {
role = this.guild._settings.mute.role; //eslint-disable-line prefer-destructuring
}
}
@ -102,4 +104,4 @@ class MuteInfraction extends Infraction {
}
module.exports = MuteInfraction;
module.exports = UnmuteInfraction;

View File

@ -71,6 +71,9 @@ class Infraction {
async handle() {
//NOTE: Temporary logging, making sure there isn't any other issues.
if(typeof this.reason !== 'string') this.client.logger.error(`Infraction type ${this.type} was passed an invalid type to the reason.`);
const { moderationLog, dmInfraction } = await this.guild.settings();
//Increment CaseId, should only be called if making a new infraction.
@ -206,7 +209,7 @@ class Infraction {
reason: this.reason,
data: this.data,
flags: this.flags,
modLogMessage: this.modLogMessageId,
modLogMessage: this.modlogMessageId,
dmLogMessage: this.dmlogMessageId,
modLogChannel: this.modlogId,
resolved: this.resolved,

View File

@ -99,7 +99,7 @@ class Util {
}
static escapeMarkdown(text, options) {
if (!text) return;
if(typeof text !== 'string') return text;
return DiscordUtil.escapeMarkdown(text, options);
}