forked from Galactic/galactic-bot
bugfixes?
This commit is contained in:
parent
a0a8cf6c3a
commit
e6ce4e84e1
@ -158,7 +158,7 @@ class GuildWrapper {
|
|||||||
let { settings, _imported } = data;
|
let { settings, _imported } = data;
|
||||||
const { defaultConfig } = this;
|
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;
|
if (this._importPromise) settings = await this._importPromise;
|
||||||
else {
|
else {
|
||||||
this._importPromise = this._attemptDataImport();
|
this._importPromise = this._attemptDataImport();
|
||||||
|
@ -123,7 +123,10 @@ module.exports = class AutoModeration extends Observer {
|
|||||||
|
|
||||||
async filterWords(message, edited) {
|
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;
|
if (!guild || author.bot || message.filtered) return;
|
||||||
|
|
||||||
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
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) {
|
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;
|
if (!guild || author.bot) return;
|
||||||
|
|
||||||
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
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) {
|
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;
|
if (!guild || author.bot || message.filtered) return;
|
||||||
|
|
||||||
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
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) {
|
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;
|
if (!guild || author.bot || message.filtered) return;
|
||||||
|
|
||||||
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
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) {
|
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;
|
if (!guild || author.bot || message.filtered) return;
|
||||||
|
|
||||||
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
const member = message.member || await guild.members.fetch(author.id).catch(() => null);
|
||||||
|
@ -68,7 +68,7 @@ class UtilityHook extends Observer {
|
|||||||
|
|
||||||
if (infraction.data.muteType === 0) {
|
if (infraction.data.muteType === 0) {
|
||||||
if (!role) return;
|
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) {
|
} else if (infraction.data.muteType === 1) {
|
||||||
|
|
||||||
if (!role) return;
|
if (!role) return;
|
||||||
@ -77,10 +77,12 @@ class UtilityHook extends Observer {
|
|||||||
const managed = roles.find((r) => r.managed);
|
const managed = roles.find((r) => r.managed);
|
||||||
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
|
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
|
||||||
|
|
||||||
|
try {
|
||||||
if (managed) {
|
if (managed) {
|
||||||
await member.roles.add(setting.role, 'automute upon rejoin, type 1');
|
await member.roles.add(setting.role, 'automute upon rejoin, type 1');
|
||||||
await member.roles.remove(remove, 'removing excess roles for type 1 mute');
|
await member.roles.remove(remove, 'removing excess roles for type 1 mute');
|
||||||
} else await member.roles.set([role], 'automute upon join, type 1');
|
} else await member.roles.set([role], 'automute upon join, type 1');
|
||||||
|
} catch { /* nothing */ }
|
||||||
|
|
||||||
} else if (infraction.data.muteType === 2) {
|
} else if (infraction.data.muteType === 2) {
|
||||||
|
|
||||||
@ -89,7 +91,7 @@ class UtilityHook extends Observer {
|
|||||||
const roles = member.roles.cache;
|
const roles = member.roles.cache;
|
||||||
const remove = roles.filter((r) => !r.managed); //Have to do this bs for managed roles -.-
|
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 { guildWrapper: guild } = member;
|
||||||
const settings = await guild.settings();
|
const settings = await guild.settings();
|
||||||
const setting = settings.autorole;
|
const setting = settings.autorole;
|
||||||
if (!setting.enabled) return;
|
if (!setting.enabled || !setting.roles) return;
|
||||||
const me = await guild.resolveMember(this.client.user);
|
const me = await guild.resolveMember(this.client.user);
|
||||||
if (!me.permissions.has('ManageRoles')) return;
|
if (!me.permissions.has('ManageRoles')) return;
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user