aiko-chan-ai / discord.js-selfbot-v13

An unofficial discord.js fork for creating selfbots
https://discordjs-self-v13.netlify.app
GNU General Public License v3.0
777 stars 165 forks source link

How do I handle error from Application Command #1040

Closed tungdo0602 closed 8 months ago

tungdo0602 commented 8 months ago

Which package has the bugs?

The core library

Issue description

I've tried many things to try handle the error such as try catch but it seem to not work.

Code sample

function retry(f, t, el="Failed to execute function, retrying..."){
    let rt = 0;
    while(rt < t){
        try {
            (f)();
            break;
        } catch {
            rt += 1
            console.log(el, `[${rt}]`);
        }
    }
}

client.on("messageCreate", function(msg) {
    if(msg.embeds.length > 0){
        let c = msg.embeds[0];
        if(msg.components.length > 0 && msg.components[0].components[0].type == "BUTTON" && msg.components[0].components[0].label == "Back To The Future"){
            try {
                msg.clickButton(msg.components[0].components[0].customId);
            } catch {
                retry(()=>mc.sendSlash("438057969251254293", "route", routeNum), 3, "Failed to send slash command, retrying...");
            }
        }
    }
});

Package version

-- discord.js-selfbot-v13@3.1.4

Node.js version

v20.5.1

Operating system

Windows 10

Priority this issue should have

Low (slightly annoying)

Checklist

Additional Information

Error: Error [INTERACTION_FAILED]: No responsed from Application Command at Timeout._onTimeout (D:\Tung\Code\Nodejs\bot\node_modules\discord.js-selfbot-v13\src\structures\Message.js:1063:16) at listOnTimeout (node:internal/timers:573:17) at process.processTimers (node:internal/timers:514:7) {

}

Damnbuoy commented 2 months ago

Im still getting exact the same issue, I can't handle the error so it just crashes. Im using the version and I checked for duplicate issues too but none of them had the answer.