Lots of slash command work, added workaround for eris-fleet request debugging
This commit is contained in:
parent
b8aeb6625a
commit
2cffdf6628
61 changed files with 417 additions and 244 deletions
|
@ -4,22 +4,28 @@ import { log } from "./logger.js";
|
|||
let queryValue = 0;
|
||||
|
||||
// load command into memory
|
||||
export async function load(command, soundStatus) {
|
||||
export async function load(client, cluster, worker, ipc, command, soundStatus) {
|
||||
const { default: props } = await import(`${command}?v=${queryValue}`);
|
||||
queryValue++;
|
||||
if (props.requires.includes("sound") && soundStatus) return log("warn", `Failed to connect to some Lavalink nodes, skipped loading command ${command}...`);
|
||||
if (props.requires.includes("sound") && soundStatus) {
|
||||
log("warn", `Failed to connect to some Lavalink nodes, skipped loading command ${command}...`);
|
||||
return;
|
||||
}
|
||||
const commandArray = command.split("/");
|
||||
const commandName = commandArray[commandArray.length - 1].split(".")[0];
|
||||
|
||||
paths.set(commandName, command);
|
||||
commands.set(commandName, props);
|
||||
|
||||
const propsInstance = new props(client, cluster, worker, ipc, {});
|
||||
|
||||
info.set(commandName, {
|
||||
category: commandArray[commandArray.length - 2],
|
||||
description: props.description,
|
||||
aliases: props.aliases,
|
||||
params: props.arguments,
|
||||
flags: props.flags
|
||||
flags: propsInstance.flags ?? props.flags,
|
||||
slashAllowed: props.slashAllowed
|
||||
});
|
||||
|
||||
if (props.aliases) {
|
||||
|
@ -28,5 +34,5 @@ export async function load(command, soundStatus) {
|
|||
paths.set(alias, command);
|
||||
}
|
||||
}
|
||||
return false;
|
||||
return commandName;
|
||||
}
|
||||
|
|
|
@ -106,10 +106,10 @@ const checkImages = async (message, extraReturnTypes, video, sticker) => {
|
|||
// embeds can vary in types, we check for tenor gifs first
|
||||
if (message.embeds[0].type === "gifv") {
|
||||
type = await getImage(message.embeds[0].video.url, message.embeds[0].url, video, extraReturnTypes, true);
|
||||
// then we check for other image types
|
||||
// then we check for other image types
|
||||
} else if ((message.embeds[0].type === "video" || message.embeds[0].type === "image") && message.embeds[0].thumbnail) {
|
||||
type = await getImage(message.embeds[0].thumbnail.proxy_url, message.embeds[0].thumbnail.url, video, extraReturnTypes);
|
||||
// finally we check both possible image fields for "generic" embeds
|
||||
// finally we check both possible image fields for "generic" embeds
|
||||
} else if (message.embeds[0].type === "rich" || message.embeds[0].type === "article") {
|
||||
if (message.embeds[0].thumbnail) {
|
||||
type = await getImage(message.embeds[0].thumbnail.proxy_url, message.embeds[0].thumbnail.url, video, extraReturnTypes);
|
||||
|
@ -117,7 +117,7 @@ const checkImages = async (message, extraReturnTypes, video, sticker) => {
|
|||
type = await getImage(message.embeds[0].image.proxy_url, message.embeds[0].image.url, video, extraReturnTypes);
|
||||
}
|
||||
}
|
||||
// then check the attachments
|
||||
// then check the attachments
|
||||
} else if (message.attachments.length !== 0 && message.attachments[0].width) {
|
||||
type = await getImage(message.attachments[0].proxy_url, message.attachments[0].url, video);
|
||||
}
|
||||
|
@ -127,20 +127,34 @@ const checkImages = async (message, extraReturnTypes, video, sticker) => {
|
|||
};
|
||||
|
||||
// this checks for the latest message containing an image and returns the url of the image
|
||||
export default async (client, cmdMessage, extraReturnTypes = false, video = false, sticker = false) => {
|
||||
// we start by checking if the message is a reply to another message
|
||||
if (cmdMessage.messageReference) {
|
||||
const replyMessage = await client.getMessage(cmdMessage.messageReference.channelID, cmdMessage.messageReference.messageID).catch(() => undefined);
|
||||
if (replyMessage) {
|
||||
const replyResult = await checkImages(replyMessage, extraReturnTypes, video, sticker);
|
||||
if (replyResult !== false) return replyResult;
|
||||
export default async (client, cmdMessage, interaction, options, extraReturnTypes = false, video = false, sticker = false) => {
|
||||
// we start by determining whether or not we're dealing with an interaction or a message
|
||||
if (interaction) {
|
||||
// we can get a raw attachment or a URL in the interaction itself
|
||||
if (options) {
|
||||
if (options.image) {
|
||||
const result = await getImage(options.image.proxy_url, options.image.url, video);
|
||||
if (result !== false) return result;
|
||||
} else if (options.link) {
|
||||
const result = await getImage(options.link, options.link, video);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
// check if the message is a reply to another message
|
||||
if (cmdMessage.messageReference) {
|
||||
const replyMessage = await client.getMessage(cmdMessage.messageReference.channelID, cmdMessage.messageReference.messageID).catch(() => undefined);
|
||||
if (replyMessage) {
|
||||
const replyResult = await checkImages(replyMessage, extraReturnTypes, video, sticker);
|
||||
if (replyResult !== false) return replyResult;
|
||||
}
|
||||
}
|
||||
// then we check the current message
|
||||
const result = await checkImages(cmdMessage, extraReturnTypes, video, sticker);
|
||||
if (result !== false) return result;
|
||||
}
|
||||
// then we check the current message
|
||||
const result = await checkImages(cmdMessage, extraReturnTypes, video, sticker);
|
||||
if (result !== false) return result;
|
||||
// if there aren't any replies then iterate over the last few messages in the channel
|
||||
const messages = await client.getMessages(cmdMessage.channel.id);
|
||||
// if there aren't any replies or interaction attachments then iterate over the last few messages in the channel
|
||||
const messages = await client.getMessages((interaction ? interaction : cmdMessage).channel.id);
|
||||
// iterate over each message
|
||||
for (const message of messages) {
|
||||
const result = await checkImages(message, extraReturnTypes, video, sticker);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue