diff --git a/structure/client/components/commands/moderation/Mute.js b/structure/client/components/commands/moderation/Mute.js index 5cadfa3..534dc1a 100644 --- a/structure/client/components/commands/moderation/Mute.js +++ b/structure/client/components/commands/moderation/Mute.js @@ -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(' ') }); } diff --git a/structure/extensions/Guild.js b/structure/extensions/Guild.js index 6f4c954..8cc63cd 100644 --- a/structure/extensions/Guild.js +++ b/structure/extensions/Guild.js @@ -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) { diff --git a/structure/extensions/GuildMember.js b/structure/extensions/GuildMember.js index 658553d..a63378d 100644 --- a/structure/extensions/GuildMember.js +++ b/structure/extensions/GuildMember.js @@ -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; diff --git a/structure/moderation/ModerationManager.js b/structure/moderation/ModerationManager.js index 62e6787..3a0857a 100644 --- a/structure/moderation/ModerationManager.js +++ b/structure/moderation/ModerationManager.js @@ -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 }); diff --git a/structure/moderation/infractions/Unmute.js b/structure/moderation/infractions/Unmute.js index 1eaa22d..cff5d76 100644 --- a/structure/moderation/infractions/Unmute.js +++ b/structure/moderation/infractions/Unmute.js @@ -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; \ No newline at end of file +module.exports = UnmuteInfraction; \ No newline at end of file diff --git a/structure/moderation/interfaces/Infraction.js b/structure/moderation/interfaces/Infraction.js index 3bb81cb..fa9bd14 100644 --- a/structure/moderation/interfaces/Infraction.js +++ b/structure/moderation/interfaces/Infraction.js @@ -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, diff --git a/util/Util.js b/util/Util.js index 31c28ec..0da8bfd 100644 --- a/util/Util.js +++ b/util/Util.js @@ -99,7 +99,7 @@ class Util { } static escapeMarkdown(text, options) { - console.log(text); + if(typeof text !== 'string') return text; return DiscordUtil.escapeMarkdown(text, options); }