Fix slash command "link" field not working with gifvs, update packages

This commit is contained in:
Essem 2022-07-19 21:06:51 -05:00
parent 36477ed253
commit 93fa8e8098
No known key found for this signature in database
GPG key ID: 7D497397CC3A2A8C
4 changed files with 249 additions and 242 deletions

View file

@ -23,8 +23,9 @@ export default async (client, cluster, worker, ipc, interaction) => {
// eslint-disable-next-line no-unused-vars
const commandClass = new cmd(client, cluster, worker, ipc, { type: "application", interaction });
const result = await commandClass.run();
const replyMethod = interaction.acknowledged ? "editOriginalMessage" : "createMessage";
if (typeof result === "string" || (typeof result === "object" && result.embeds)) {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"](result);
await interaction[replyMethod](result);
} else if (typeof result === "object" && result.file) {
let fileSize = 8388119;
if (interaction.channel.guild) {
@ -41,23 +42,24 @@ export default async (client, cluster, worker, ipc, interaction) => {
if (process.env.TEMPDIR && process.env.TEMPDIR !== "") {
await upload(client, result, interaction, true);
} else {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"]("The resulting image was more than 8MB in size, so I can't upload it.");
await interaction[replyMethod]("The resulting image was more than 8MB in size, so I can't upload it.");
}
} else {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"](result.text ? result.text : {}, result);
await interaction[replyMethod](result.text ? result.text : {}, result);
}
}
} catch (error) {
const replyMethod = interaction.acknowledged ? "editOriginalMessage" : "createMessage";
if (error.toString().includes("Request entity too large")) {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"]("The resulting file was too large to upload. Try again with a smaller image if possible.");
await interaction[replyMethod]("The resulting file was too large to upload. Try again with a smaller image if possible.");
} else if (error.toString().includes("Job ended prematurely")) {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"]("Something happened to the image servers before I could receive the image. Try running your command again.");
await interaction[replyMethod]("Something happened to the image servers before I could receive the image. Try running your command again.");
} else if (error.toString().includes("Timed out")) {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"]("The request timed out before I could download that image. Try uploading your image somewhere else or reducing its size.");
await interaction[replyMethod]("The request timed out before I could download that image. Try uploading your image somewhere else or reducing its size.");
} else {
logger.error(`Error occurred with slash command ${command} with arguments ${JSON.stringify(interaction.data.options)}: ${typeof error === "object" ? JSON.stringify(error) : error.toString()}`);
try {
await interaction[interaction.acknowledged ? "editOriginalMessage" : "createMessage"]("Uh oh! I ran into an error while running this command. Please report the content of the attached file at the following link or on the esmBot Support server: <https://github.com/esmBot/esmBot/issues>", {
await interaction[replyMethod]("Uh oh! I ran into an error while running this command. Please report the content of the attached file at the following link or on the esmBot Support server: <https://github.com/esmBot/esmBot/issues>", {
file: `Message: ${await clean(error)}\n\nStack Trace: ${await clean(error.stack)}`,
name: "error.txt"
});