Replace eris-fleet with a pm2-based cluster system, overhaul image handling, removed azure image api

This commit is contained in:
Essem 2022-09-21 00:05:03 -05:00
parent 5a3364736d
commit db0decf71a
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
45 changed files with 1777 additions and 857 deletions

View file

@ -1,5 +1,5 @@
import { debug } from "../utils/logger.js";
export default async (client, cluster, worker, ipc, message) => {
export default async (client, message) => {
debug(message);
};

5
events/error.js Normal file
View file

@ -0,0 +1,5 @@
import { error } from "../utils/logger.js";
export default async (client, message) => {
error(message);
};

View file

@ -2,7 +2,7 @@ import db from "../utils/database.js";
import { log } from "../utils/logger.js";
// run when the bot is added to a guild
export default async (client, cluster, worker, ipc, guild) => {
export default async (client, guild) => {
log(`[GUILD JOIN] ${guild.name} (${guild.id}) added the bot.`);
const guildDB = await db.getGuild(guild.id);
if (!guildDB) await db.addGuild(guild);

View file

@ -1,6 +1,6 @@
import { log } from "../utils/logger.js";
// run when the bot is removed from a guild
export default async (client, cluster, worker, ipc, guild) => {
export default async (client, guild) => {
log(`[GUILD LEAVE] ${guild.name} (${guild.id}) removed the bot.`);
};

View file

@ -5,7 +5,7 @@ import { clean } from "../utils/misc.js";
import { upload } from "../utils/tempimages.js";
// run when a slash command is executed
export default async (client, cluster, worker, ipc, interaction) => {
export default async (client, interaction) => {
if (interaction?.type !== 2) return;
// check if command exists and if it's enabled
@ -23,7 +23,7 @@ export default async (client, cluster, worker, ipc, interaction) => {
try {
await database.addCount(command);
// eslint-disable-next-line no-unused-vars
const commandClass = new cmd(client, cluster, worker, ipc, { type: "application", interaction });
const commandClass = new cmd(client, { type: "application", interaction });
const result = await commandClass.run();
const replyMethod = interaction.acknowledged ? "editOriginalMessage" : "createMessage";
if (typeof result === "string") {
@ -39,7 +39,7 @@ export default async (client, cluster, worker, ipc, interaction) => {
const fileSize = 8388119;
if (result.file.length > fileSize) {
if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
await upload(client, ipc, result, interaction, true);
await upload(client, result, interaction, true);
} else {
await interaction[replyMethod]({
content: "The resulting image was more than 8MB in size, so I can't upload it.",

View file

@ -6,7 +6,7 @@ import { clean } from "../utils/misc.js";
import { upload } from "../utils/tempimages.js";
// run when someone sends a message
export default async (client, cluster, worker, ipc, message) => {
export default async (client, message) => {
// ignore other bots
if (message.author.bot) return;
@ -104,7 +104,7 @@ export default async (client, cluster, worker, ipc, message) => {
await database.addCount(aliases.get(command) ?? command);
const startTime = new Date();
// eslint-disable-next-line no-unused-vars
const commandClass = new cmd(client, cluster, worker, ipc, { type: "classic", message, args: parsed._, content: message.content.substring(prefix.length).trim().replace(command, "").trim(), specialArgs: (({ _, ...o }) => o)(parsed) }); // we also provide the message content as a parameter for cases where we need more accuracy
const commandClass = new cmd(client, { type: "classic", message, args: parsed._, content: message.content.substring(prefix.length).trim().replace(command, "").trim(), specialArgs: (({ _, ...o }) => o)(parsed) }); // we also provide the message content as a parameter for cases where we need more accuracy
const result = await commandClass.run();
const endTime = new Date();
if ((endTime - startTime) >= 180000) reference.allowedMentions.repliedUser = true;
@ -129,7 +129,7 @@ export default async (client, cluster, worker, ipc, message) => {
}
if (result.file.length > fileSize) {
if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
await upload(client, ipc, result, message);
await upload(client, result, message);
} else {
await client.createMessage(message.channel.id, "The resulting image was more than 8MB in size, so I can't upload it.");
}

View file

@ -4,7 +4,7 @@ import { random } from "../utils/misc.js";
const isWaiting = new Map();
export default async (client, cluster, worker, ipc, member, oldChannel) => {
export default async (client, member, oldChannel) => {
if (!oldChannel) return;
const connection = players.get(oldChannel.guild.id);
if (oldChannel.id === connection?.voiceChannel.id) {

View file

@ -1,5 +1,5 @@
import leaveHandler from "./voiceChannelLeave.js";
export default async (client, cluster, worker, ipc, member, newChannel, oldChannel) => {
await leaveHandler(client, cluster, worker, ipc, member, oldChannel);
export default async (client, member, newChannel, oldChannel) => {
await leaveHandler(client, member, oldChannel);
};

5
events/warn.js Normal file
View file

@ -0,0 +1,5 @@
import { warn } from "../utils/logger.js";
export default async (client, message) => {
warn(message);
};