mirror of
https://github.com/ZeppelinBot/Zeppelin.git
synced 2025-03-16 14:11:50 +00:00
renamed ErisError to DiscordJSError, use rateLimit event instead of debug, renamed the TOKEN variable back
This commit is contained in:
parent
1e69da7cbc
commit
77b33c1858
2 changed files with 8 additions and 13 deletions
|
@ -1,6 +1,6 @@
|
||||||
import util from "util";
|
import util from "util";
|
||||||
|
|
||||||
export class ErisError extends Error {
|
export class DiscordJSError extends Error {
|
||||||
code: number | string | undefined;
|
code: number | string | undefined;
|
||||||
shardId: number;
|
shardId: number;
|
||||||
|
|
||||||
|
@ -11,6 +11,6 @@ export class ErisError extends Error {
|
||||||
}
|
}
|
||||||
|
|
||||||
[util.inspect.custom]() {
|
[util.inspect.custom]() {
|
||||||
return `[ERIS] [ERROR CODE ${this.code || "?"}] [SHARD ${this.shardId}] ${this.message}`;
|
return `[DISCORDJS] [ERROR CODE ${this.code ?? "?"}] [SHARD ${this.shardId}] ${this.message}`;
|
||||||
}
|
}
|
||||||
}
|
}
|
|
@ -1,5 +1,4 @@
|
||||||
import { Client, Intents, TextChannel } from "discord.js";
|
import { Client, Intents, TextChannel } from "discord.js";
|
||||||
import fs from "fs";
|
|
||||||
import yaml from "js-yaml";
|
import yaml from "js-yaml";
|
||||||
import { Knub, PluginError } from "knub";
|
import { Knub, PluginError } from "knub";
|
||||||
import { PluginLoadError } from "knub/dist/plugins/PluginLoadError";
|
import { PluginLoadError } from "knub/dist/plugins/PluginLoadError";
|
||||||
|
@ -11,7 +10,7 @@ import { Configs } from "./data/Configs";
|
||||||
import { connect } from "./data/db";
|
import { connect } from "./data/db";
|
||||||
import { GuildLogs } from "./data/GuildLogs";
|
import { GuildLogs } from "./data/GuildLogs";
|
||||||
import { LogType } from "./data/LogType";
|
import { LogType } from "./data/LogType";
|
||||||
import { ErisError } from "./ErisError";
|
import { DiscordJSError } from "./DiscordJSError";
|
||||||
import "./loadEnv";
|
import "./loadEnv";
|
||||||
import { logger } from "./logger";
|
import { logger } from "./logger";
|
||||||
import { baseGuildPlugins, globalPlugins, guildPlugins } from "./plugins/availablePlugins";
|
import { baseGuildPlugins, globalPlugins, guildPlugins } from "./plugins/availablePlugins";
|
||||||
|
@ -21,8 +20,6 @@ import { ZeppelinGlobalConfig, ZeppelinGuildConfig } from "./types";
|
||||||
import { startUptimeCounter } from "./uptime";
|
import { startUptimeCounter } from "./uptime";
|
||||||
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, successMessage } from "./utils";
|
import { errorMessage, isDiscordAPIError, isDiscordHTTPError, successMessage } from "./utils";
|
||||||
|
|
||||||
const fsp = fs.promises;
|
|
||||||
|
|
||||||
if (!process.env.KEY) {
|
if (!process.env.KEY) {
|
||||||
// tslint:disable-next-line:no-console
|
// tslint:disable-next-line:no-console
|
||||||
console.error("Project root .env with KEY is required!");
|
console.error("Project root .env with KEY is required!");
|
||||||
|
@ -81,7 +78,7 @@ function errorHandler(err) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (err instanceof ErisError) {
|
if (err instanceof DiscordJSError) {
|
||||||
if (err.code && SAFE_TO_IGNORE_ERIS_ERROR_CODES.includes(err.code)) {
|
if (err.code && SAFE_TO_IGNORE_ERIS_ERROR_CODES.includes(err.code)) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
@ -176,14 +173,12 @@ connect().then(async () => {
|
||||||
});
|
});
|
||||||
client.setMaxListeners(200);
|
client.setMaxListeners(200);
|
||||||
|
|
||||||
client.on("debug", message => {
|
client.on("rateLimit", rateLimitData => {
|
||||||
if (message.includes(" 429 ")) {
|
logger.info(`[429] ${rateLimitData}`);
|
||||||
logger.info(`[429] ${message}`);
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
client.on("error", err => {
|
client.on("error", err => {
|
||||||
errorHandler(new ErisError(err.message, (err as any).code, 0));
|
errorHandler(new DiscordJSError(err.message, (err as any).code, 0));
|
||||||
});
|
});
|
||||||
|
|
||||||
const allowedGuilds = new AllowedGuilds();
|
const allowedGuilds = new AllowedGuilds();
|
||||||
|
@ -266,5 +261,5 @@ connect().then(async () => {
|
||||||
bot.initialize();
|
bot.initialize();
|
||||||
logger.info("Bot Initialized");
|
logger.info("Bot Initialized");
|
||||||
logger.info("Logging in...");
|
logger.info("Logging in...");
|
||||||
await client.login(process.env.token);
|
await client.login(process.env.TOKEN);
|
||||||
});
|
});
|
||||||
|
|
Loading…
Add table
Reference in a new issue