mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 22:21:51 +00:00
Optimizations + debug logging
This commit is contained in:
parent
a84fb87324
commit
6ed8aba35f
3 changed files with 16 additions and 3 deletions
|
@ -53,6 +53,10 @@ export type UnmuteResult = {
|
||||||
case: Case;
|
case: Case;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
const EXPIRED_MUTE_CHECK_INTERVAL = 60 * 1000;
|
||||||
|
let FIRST_CHECK_TIME = Date.now();
|
||||||
|
const FIRST_CHECK_INCREMENT = 5 * 1000;
|
||||||
|
|
||||||
export class MutesPlugin extends ZeppelinPlugin<IMutesPluginConfig> {
|
export class MutesPlugin extends ZeppelinPlugin<IMutesPluginConfig> {
|
||||||
public static pluginName = "mutes";
|
public static pluginName = "mutes";
|
||||||
|
|
||||||
|
@ -99,8 +103,13 @@ export class MutesPlugin extends ZeppelinPlugin<IMutesPluginConfig> {
|
||||||
this.serverLogs = new GuildLogs(this.guildId);
|
this.serverLogs = new GuildLogs(this.guildId);
|
||||||
|
|
||||||
// Check for expired mutes every 5s
|
// Check for expired mutes every 5s
|
||||||
this.clearExpiredMutes();
|
const firstCheckTime = Math.max(Date.now(), FIRST_CHECK_TIME) + FIRST_CHECK_INCREMENT;
|
||||||
this.muteClearIntervalId = setInterval(() => this.clearExpiredMutes(), 5000);
|
FIRST_CHECK_TIME = firstCheckTime;
|
||||||
|
|
||||||
|
setTimeout(() => {
|
||||||
|
this.clearExpiredMutes();
|
||||||
|
this.muteClearIntervalId = setInterval(() => this.clearExpiredMutes(), EXPIRED_MUTE_CHECK_INTERVAL);
|
||||||
|
}, firstCheckTime - Date.now());
|
||||||
}
|
}
|
||||||
|
|
||||||
protected onUnload() {
|
protected onUnload() {
|
||||||
|
|
|
@ -10,6 +10,7 @@ import DiscordRESTError from "eris/lib/errors/DiscordRESTError"; // tslint:disab
|
||||||
|
|
||||||
const NATIVE_SLOWMODE_LIMIT = 6 * 60 * 60; // 6 hours
|
const NATIVE_SLOWMODE_LIMIT = 6 * 60 * 60; // 6 hours
|
||||||
const MAX_SLOWMODE = 60 * 60 * 24 * 365 * 100; // 100 years
|
const MAX_SLOWMODE = 60 * 60 * 24 * 365 * 100; // 100 years
|
||||||
|
const BOT_SLOWMODE_CLEAR_INTERVAL = 60 * 1000;
|
||||||
|
|
||||||
interface ISlowmodePluginConfig {
|
interface ISlowmodePluginConfig {
|
||||||
use_native_slowmode: boolean;
|
use_native_slowmode: boolean;
|
||||||
|
@ -51,7 +52,7 @@ export class SlowmodePlugin extends ZeppelinPlugin<ISlowmodePluginConfig> {
|
||||||
onLoad() {
|
onLoad() {
|
||||||
this.slowmodes = GuildSlowmodes.getInstance(this.guildId);
|
this.slowmodes = GuildSlowmodes.getInstance(this.guildId);
|
||||||
this.savedMessages = GuildSavedMessages.getInstance(this.guildId);
|
this.savedMessages = GuildSavedMessages.getInstance(this.guildId);
|
||||||
this.clearInterval = setInterval(() => this.clearExpiredSlowmodes(), 2000);
|
this.clearInterval = setInterval(() => this.clearExpiredSlowmodes(), BOT_SLOWMODE_CLEAR_INTERVAL);
|
||||||
|
|
||||||
this.onMessageCreateFn = this.onMessageCreate.bind(this);
|
this.onMessageCreateFn = this.onMessageCreate.bind(this);
|
||||||
this.savedMessages.events.on("create", this.onMessageCreateFn);
|
this.savedMessages.events.on("create", this.onMessageCreateFn);
|
||||||
|
|
|
@ -600,6 +600,9 @@ export async function resolveMember(bot: Client, guild: Guild, value: string): P
|
||||||
// If not, fetch it from the API
|
// If not, fetch it from the API
|
||||||
if (!member) {
|
if (!member) {
|
||||||
try {
|
try {
|
||||||
|
logger.info(`Fetching unknown member (${user.id} in ${guild.name} (${guild.id})) from the API`);
|
||||||
|
console.trace();
|
||||||
|
|
||||||
member = await bot.getRESTGuildMember(guild.id, user.id);
|
member = await bot.getRESTGuildMember(guild.id, user.id);
|
||||||
member.id = user.id;
|
member.id = user.id;
|
||||||
member.guild = guild;
|
member.guild = guild;
|
||||||
|
|
Loading…
Add table
Reference in a new issue