forked from Galactic/galactic-bot
Bugfix to modstats
Bugfix to getGuildWrapper
This commit is contained in:
parent
7ca623c3c7
commit
bc787738ac
@ -490,14 +490,29 @@ class DiscordClient extends Client
|
||||
return this.localeLoader.format(language, index, params, code);
|
||||
}
|
||||
|
||||
getGuildWrapper (id: string)
|
||||
async getGuildWrapper (id: string)
|
||||
{
|
||||
if (this.#guildWrappers.has(id))
|
||||
return this.#guildWrappers.get(id);
|
||||
if (!this.guilds.cache.has(id))
|
||||
throw new Error('Guild is not present on client');
|
||||
return this.#guildWrappers.get(id)!;
|
||||
let guild = this.guilds.cache.get(id);
|
||||
if (!guild)
|
||||
guild = await this.guilds.fetch({ guild: id, cache: true });
|
||||
if (!guild)
|
||||
throw new Error('Guild does not exist');
|
||||
|
||||
const wrapper = new GuildWrapper(this, this.guilds.cache.get(id) as Guild);
|
||||
const wrapper = new GuildWrapper(this, guild);
|
||||
this.#guildWrappers.set(id, wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
|
||||
getGuildWrapperSync (id: string)
|
||||
{
|
||||
if (this.#guildWrappers.has(id))
|
||||
return this.#guildWrappers.get(id)!;
|
||||
const guild = this.guilds.cache.get(id);
|
||||
if (!guild)
|
||||
return null;
|
||||
const wrapper = new GuildWrapper(this, guild);
|
||||
this.#guildWrappers.set(id, wrapper);
|
||||
return wrapper;
|
||||
}
|
||||
@ -510,7 +525,7 @@ class DiscordClient extends Client
|
||||
{
|
||||
const id = typeof resolveable === 'string' ? resolveable : resolveable.id;
|
||||
|
||||
if (this.#userWrappers.has(id))
|
||||
if (this.#userWrappers.has(id) && !fetch)
|
||||
return this.#userWrappers.get(id) || null;
|
||||
|
||||
if (!fetch)
|
||||
|
@ -79,7 +79,7 @@ class EventHooker
|
||||
{
|
||||
if (arg && typeof arg === 'object' && 'guild' in arg && arg.guild)
|
||||
{
|
||||
const wrapper = this.#target.getGuildWrapper(arg.guild!.id);
|
||||
const wrapper = await this.#target.getGuildWrapper(arg.guild!.id);
|
||||
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||
// @ts-ignore
|
||||
arg.guildWrapper = wrapper;
|
||||
|
@ -71,11 +71,8 @@ class ModstatsCommand extends SlashCommand
|
||||
(result.data[log.executor][log.type] as number)++;
|
||||
}
|
||||
|
||||
for (const user of Object.keys(result))
|
||||
for (const user of Object.keys(result.data))
|
||||
{
|
||||
if ([ 'time', 'totals' ].includes(user))
|
||||
continue;
|
||||
|
||||
let sum = 0;
|
||||
if (!result.totals.sum)
|
||||
result.totals.sum = 0;
|
||||
|
@ -409,7 +409,7 @@ export default class AutoModeration extends Observer implements Initialisable
|
||||
const [ , actionType ] = customId.split('_');
|
||||
const { permissions } = this.client;
|
||||
|
||||
const guild = this.client.getGuildWrapper(interaction.guildId);
|
||||
const guild = await this.client.getGuildWrapper(interaction.guildId);
|
||||
if (!guild)
|
||||
return;
|
||||
const moderator = await guild.memberWrapper(interaction.user.id);
|
||||
|
@ -409,7 +409,7 @@ class GuildLogger extends Observer
|
||||
if (!guild || partial)
|
||||
return;
|
||||
|
||||
const wrapper = this.client.getGuildWrapper(guild.id);
|
||||
const wrapper = await this.client.getGuildWrapper(guild.id);
|
||||
if (!wrapper)
|
||||
return;
|
||||
const settings = await wrapper.settings();
|
||||
|
@ -226,7 +226,7 @@ class UtilityHook extends Observer
|
||||
if (!message.guildId)
|
||||
return;
|
||||
|
||||
const guild = this.client.getGuildWrapper(message.guildId);
|
||||
const guild = await this.client.getGuildWrapper(message.guildId);
|
||||
if (!guild)
|
||||
return;
|
||||
const channel = await guild.resolveChannel<TextChannel>(message.channelId);
|
||||
@ -258,7 +258,9 @@ class UtilityHook extends Observer
|
||||
return;
|
||||
const { guild: g, message, customId, author, channel, values } = interaction;
|
||||
let { member } = interaction;
|
||||
const guild = this.client.getGuildWrapper(g?.id ?? '');
|
||||
if (!g)
|
||||
return;
|
||||
const guild = await this.client.getGuildWrapper(g.id);
|
||||
if (!guild || !member || !customId?.includes('selfrole') || !message || !values)
|
||||
return;
|
||||
const { selfrole } = await guild.settings();
|
||||
|
@ -37,7 +37,7 @@ class InteractionWrapper<InGuild extends boolean = boolean>
|
||||
constructor (client: DiscordClient, interaction: Interaction)
|
||||
{
|
||||
if (interaction.guildId)
|
||||
this.#guild = (client.getGuildWrapper(interaction.guildId) ?? null) as If<InGuild, GuildWrapper>;
|
||||
this.#guild = client.getGuildWrapperSync(interaction.guildId) as If<InGuild, GuildWrapper>;
|
||||
else
|
||||
this.#guild = null as If<InGuild, GuildWrapper>;
|
||||
|
||||
|
@ -21,7 +21,7 @@ class MessageWrapper<InGuild extends boolean = boolean>
|
||||
this.#client = client;
|
||||
this.#message = message;
|
||||
if (message.guildId)
|
||||
this.#guild = (client.getGuildWrapper(message.guildId) ?? null) as If<InGuild, GuildWrapper>;
|
||||
this.#guild = client.getGuildWrapperSync(message.guildId) as If<InGuild, GuildWrapper>;
|
||||
else
|
||||
this.#guild = null as If<InGuild, GuildWrapper>;
|
||||
|
||||
|
@ -18,15 +18,16 @@ const FilterPresets: {
|
||||
"slurs": [
|
||||
"n(ae|ji|j|y|i|x|!|1|\\||l)(gg?|qq?|99?|bb)((e|3)r|let|ur|\\s?nog|y|ah?|or)s?",
|
||||
"nick\\s?(&\\s)?(gurr?|ger|ga)",
|
||||
"(fur\\s?)?f(e|a|4|x)(gg?|qq|99?)(otry|ots|ot|y|s)?",
|
||||
"(fur\\s?)?f(e|a|4|x)(gg?|qq?|99?)(otry|ots|ot|y|s)?",
|
||||
"(fur\\s?)?fgg?ts?",
|
||||
"negro(id|e)?s?",
|
||||
"g(o|0)(o|0)k",
|
||||
"(?<!su)spic(?!y|e)",
|
||||
"ch(i|1)nk",
|
||||
"beaners?",
|
||||
"(?<!rac?)coon",
|
||||
"trann(y|ie)s?"
|
||||
"(?<!rac?)c(o|0)(o|0)n",
|
||||
"trann(y|ie)s?",
|
||||
"tr(o|0)(o|0)+ns?"
|
||||
],
|
||||
"obscene": [
|
||||
"l(o|0)l(i|1)(c(o|0)n)?",
|
||||
|
Loading…
Reference in New Issue
Block a user