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);
|
return this.localeLoader.format(language, index, params, code);
|
||||||
}
|
}
|
||||||
|
|
||||||
getGuildWrapper (id: string)
|
async getGuildWrapper (id: string)
|
||||||
{
|
{
|
||||||
if (this.#guildWrappers.has(id))
|
if (this.#guildWrappers.has(id))
|
||||||
return this.#guildWrappers.get(id);
|
return this.#guildWrappers.get(id)!;
|
||||||
if (!this.guilds.cache.has(id))
|
let guild = this.guilds.cache.get(id);
|
||||||
throw new Error('Guild is not present on client');
|
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);
|
this.#guildWrappers.set(id, wrapper);
|
||||||
return wrapper;
|
return wrapper;
|
||||||
}
|
}
|
||||||
@ -510,7 +525,7 @@ class DiscordClient extends Client
|
|||||||
{
|
{
|
||||||
const id = typeof resolveable === 'string' ? resolveable : resolveable.id;
|
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;
|
return this.#userWrappers.get(id) || null;
|
||||||
|
|
||||||
if (!fetch)
|
if (!fetch)
|
||||||
|
@ -79,7 +79,7 @@ class EventHooker
|
|||||||
{
|
{
|
||||||
if (arg && typeof arg === 'object' && 'guild' in arg && arg.guild)
|
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
|
// eslint-disable-next-line @typescript-eslint/ban-ts-comment
|
||||||
// @ts-ignore
|
// @ts-ignore
|
||||||
arg.guildWrapper = wrapper;
|
arg.guildWrapper = wrapper;
|
||||||
|
@ -71,11 +71,8 @@ class ModstatsCommand extends SlashCommand
|
|||||||
(result.data[log.executor][log.type] as number)++;
|
(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;
|
let sum = 0;
|
||||||
if (!result.totals.sum)
|
if (!result.totals.sum)
|
||||||
result.totals.sum = 0;
|
result.totals.sum = 0;
|
||||||
|
@ -409,7 +409,7 @@ export default class AutoModeration extends Observer implements Initialisable
|
|||||||
const [ , actionType ] = customId.split('_');
|
const [ , actionType ] = customId.split('_');
|
||||||
const { permissions } = this.client;
|
const { permissions } = this.client;
|
||||||
|
|
||||||
const guild = this.client.getGuildWrapper(interaction.guildId);
|
const guild = await this.client.getGuildWrapper(interaction.guildId);
|
||||||
if (!guild)
|
if (!guild)
|
||||||
return;
|
return;
|
||||||
const moderator = await guild.memberWrapper(interaction.user.id);
|
const moderator = await guild.memberWrapper(interaction.user.id);
|
||||||
|
@ -409,7 +409,7 @@ class GuildLogger extends Observer
|
|||||||
if (!guild || partial)
|
if (!guild || partial)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const wrapper = this.client.getGuildWrapper(guild.id);
|
const wrapper = await this.client.getGuildWrapper(guild.id);
|
||||||
if (!wrapper)
|
if (!wrapper)
|
||||||
return;
|
return;
|
||||||
const settings = await wrapper.settings();
|
const settings = await wrapper.settings();
|
||||||
|
@ -226,7 +226,7 @@ class UtilityHook extends Observer
|
|||||||
if (!message.guildId)
|
if (!message.guildId)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
const guild = this.client.getGuildWrapper(message.guildId);
|
const guild = await this.client.getGuildWrapper(message.guildId);
|
||||||
if (!guild)
|
if (!guild)
|
||||||
return;
|
return;
|
||||||
const channel = await guild.resolveChannel<TextChannel>(message.channelId);
|
const channel = await guild.resolveChannel<TextChannel>(message.channelId);
|
||||||
@ -258,7 +258,9 @@ class UtilityHook extends Observer
|
|||||||
return;
|
return;
|
||||||
const { guild: g, message, customId, author, channel, values } = interaction;
|
const { guild: g, message, customId, author, channel, values } = interaction;
|
||||||
let { member } = 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)
|
if (!guild || !member || !customId?.includes('selfrole') || !message || !values)
|
||||||
return;
|
return;
|
||||||
const { selfrole } = await guild.settings();
|
const { selfrole } = await guild.settings();
|
||||||
|
@ -37,7 +37,7 @@ class InteractionWrapper<InGuild extends boolean = boolean>
|
|||||||
constructor (client: DiscordClient, interaction: Interaction)
|
constructor (client: DiscordClient, interaction: Interaction)
|
||||||
{
|
{
|
||||||
if (interaction.guildId)
|
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
|
else
|
||||||
this.#guild = null as If<InGuild, GuildWrapper>;
|
this.#guild = null as If<InGuild, GuildWrapper>;
|
||||||
|
|
||||||
|
@ -21,7 +21,7 @@ class MessageWrapper<InGuild extends boolean = boolean>
|
|||||||
this.#client = client;
|
this.#client = client;
|
||||||
this.#message = message;
|
this.#message = message;
|
||||||
if (message.guildId)
|
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
|
else
|
||||||
this.#guild = null as If<InGuild, GuildWrapper>;
|
this.#guild = null as If<InGuild, GuildWrapper>;
|
||||||
|
|
||||||
|
@ -18,15 +18,16 @@ const FilterPresets: {
|
|||||||
"slurs": [
|
"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?",
|
"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)",
|
"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?",
|
"(fur\\s?)?fgg?ts?",
|
||||||
"negro(id|e)?s?",
|
"negro(id|e)?s?",
|
||||||
"g(o|0)(o|0)k",
|
"g(o|0)(o|0)k",
|
||||||
"(?<!su)spic(?!y|e)",
|
"(?<!su)spic(?!y|e)",
|
||||||
"ch(i|1)nk",
|
"ch(i|1)nk",
|
||||||
"beaners?",
|
"beaners?",
|
||||||
"(?<!rac?)coon",
|
"(?<!rac?)c(o|0)(o|0)n",
|
||||||
"trann(y|ie)s?"
|
"trann(y|ie)s?",
|
||||||
|
"tr(o|0)(o|0)+ns?"
|
||||||
],
|
],
|
||||||
"obscene": [
|
"obscene": [
|
||||||
"l(o|0)l(i|1)(c(o|0)n)?",
|
"l(o|0)l(i|1)(c(o|0)n)?",
|
||||||
|
Loading…
Reference in New Issue
Block a user