Replace eris-fleet with a pm2-based cluster system, overhaul image handling, removed azure image api
This commit is contained in:
parent
5a3364736d
commit
db0decf71a
45 changed files with 1777 additions and 857 deletions
|
@ -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
5
events/error.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { error } from "../utils/logger.js";
|
||||
|
||||
export default async (client, message) => {
|
||||
error(message);
|
||||
};
|
|
@ -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);
|
||||
|
|
|
@ -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.`);
|
||||
};
|
||||
|
|
|
@ -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.",
|
||||
|
|
|
@ -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.");
|
||||
}
|
||||
|
|
|
@ -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) {
|
||||
|
|
|
@ -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
5
events/warn.js
Normal file
|
@ -0,0 +1,5 @@
|
|||
import { warn } from "../utils/logger.js";
|
||||
|
||||
export default async (client, message) => {
|
||||
warn(message);
|
||||
};
|
Loading…
Add table
Add a link
Reference in a new issue