bugfixes?

This commit is contained in:
Erik 2022-09-01 13:38:46 +03:00
parent a0a8cf6c3a
commit e6ce4e84e1
Signed by: Navy.gif
GPG Key ID: 811EC0CD80E7E5FB
3 changed files with 26 additions and 13 deletions

View File

@ -158,7 +158,7 @@ class GuildWrapper {
let { settings, _imported } = data;
const { defaultConfig } = this;
if (!settings && !_imported?.settings && !_imported?.modlogs) {
if (!settings && !_imported?.settings && !_imported?.modlogs && process.env.NODE_ENV === 'staging') {
if (this._importPromise) settings = await this._importPromise;
else {
this._importPromise = this._attemptDataImport();

View File

@ -123,7 +123,10 @@ module.exports = class AutoModeration extends Observer {
async filterWords(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
const { guild, author, guildWrapper: wrapper } = message;
let { channel } = message;
if (channel.partial) channel = await channel.fetch();
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
@ -248,7 +251,9 @@ module.exports = class AutoModeration extends Observer {
async flagMessages(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
const { guild, author, guildWrapper: wrapper } = message;
let { channel } = message;
if (channel.partial) channel = await channel.fetch();
if (!guild || author.bot) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
@ -420,7 +425,9 @@ module.exports = class AutoModeration extends Observer {
async filterLinks(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
const { guild, author, guildWrapper: wrapper } = message;
let { channel } = message;
if (channel.partial) channel = await channel.fetch();
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
@ -546,7 +553,9 @@ module.exports = class AutoModeration extends Observer {
async filterInvites(message, edited) {
const { guild, author, channel, guildWrapper: wrapper } = message;
const { guild, author, guildWrapper: wrapper } = message;
let { channel } = message;
if (channel.partial) channel = await channel.fetch();
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
@ -604,7 +613,9 @@ module.exports = class AutoModeration extends Observer {
async filterMentions(message) {
const { guild, author, channel, guildWrapper: wrapper } = message;
const { guild, author, guildWrapper: wrapper } = message;
let { channel } = message;
if (channel.partial) channel = await channel.fetch();
if (!guild || author.bot || message.filtered) return;
const member = message.member || await guild.members.fetch(author.id).catch(() => null);

View File

@ -68,7 +68,7 @@ class UtilityHook extends Observer {
if (infraction.data.muteType === 0) {
if (!role) return;
await member.roles.add(setting.role, 'automute upon rejoin, type 0');
await member.roles.add(setting.role, 'automute upon rejoin, type 0').catch(() => null);
} else if (infraction.data.muteType === 1) {
if (!role) return;
@ -77,10 +77,12 @@ class UtilityHook extends Observer {
const managed = roles.find((r) => r.managed);
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
if (managed) {
await member.roles.add(setting.role, 'automute upon rejoin, type 1');
await member.roles.remove(remove, 'removing excess roles for type 1 mute');
} else await member.roles.set([role], 'automute upon join, type 1');
try {
if (managed) {
await member.roles.add(setting.role, 'automute upon rejoin, type 1');
await member.roles.remove(remove, 'removing excess roles for type 1 mute');
} else await member.roles.set([role], 'automute upon join, type 1');
} catch { /* nothing */ }
} else if (infraction.data.muteType === 2) {
@ -89,7 +91,7 @@ class UtilityHook extends Observer {
const roles = member.roles.cache;
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
await member.roles.remove(remove, 'automute upon join, type 1');
await member.roles.remove(remove, 'automute upon join, type 1').catch(() => null);
}
@ -116,7 +118,7 @@ class UtilityHook extends Observer {
const { guildWrapper: guild } = member;
const settings = await guild.settings();
const setting = settings.autorole;
if (!setting.enabled) return;
if (!setting.enabled || !setting.roles) return;
const me = await guild.resolveMember(this.client.user);
if (!me.permissions.has('ManageRoles')) return;