Custom command not integrating after loading module?

I’m trying to make a simple command that calls for a string, then repeats that string back in chat. I finally got the full code to successfully load into PhantomBot as a module after running the launch batch file, but I’m still unable to actually call the command in my Twitch chat.

Here’s my code:

(function() {
 
    $.bind('command', function(event) {
   
        var command = event.getCommand();
        var args = event.getArgs();
   
        if (command.equalsIgnoreCase('botquote')) {
            if (args[0] !== undefined) {
                $.say(args[0]);
            }
            else {
                $.say('you didnt type anything dude');
            }
        }
    });
   
    $.bind('initReady', function() {
        $.registerChatCommand('./custom/botquoteCommand.js', 'botquote', 1);
    });
});

Here’s my PhantomBot specs:

Java Version: 1.8.0_201-b09
OS Version: Windows 10 10.0 (x86)
Panel Version: 1.0.0
PhantomBot Version: 3.0.0 (Revision: fcc08b51)

And a screenshot of the command failing (in both cases no less) when another command which also needed to be enabled as a module to function works just fine:

image

Not entirely sure why that code isn’t working, as nothing is jumping out as obviously wrong, but are you aware of the !chat command? It does pretty much this same thing.

Awwww man, I shoulda looked through the list of commands a little more closely! That does pretty much exactly what this should have done. Unfortunately it doesn’t seem able to do what I wanted it for, which was to have the bot parrot other commands so as to consolidate multiple commands to one “universal” cooldown. The bot parrots back the !command but the command doesn’t activate when the bot says it I guess. Crumbs.

In any case though I’d still love to find out exactly why the command didn’t integrate. I even tried some other commands that I downloaded off github and they didn’t work either. I wonder if something’s up with my “core files”

you have the file inside of Phantombot/scripts/custom/botquoteCommand.js right? and the command shows up in Default Commands in the panel too?

It loads up into the list of modules in the panel so I’m pretty sure the path isn’t the problem (PhantomBot-3.0.0/scripts/custom/botquoteCommand.js, and the initReady registerChatCommand is directed to ./custom/botquoteCommand.js).

However, it does not load into the list of default commands. Maybe something’s up with my initReady? Maybe I’ll try copying it into /commands and changing the initReady to match, see if that changes anything.

EDIT: nope, that didn’t work either

looks like you were missing the last line mate

(function () {
    $.bind('command', function (event) {

        var command = event.getCommand();
        var args = event.getArgs();

        if (command.equalsIgnoreCase('botquote')) {
            if (args[0] !== undefined) {
                $.say(args[0]);
            }
            else {
                $.say('you didnt type anything dude');
            }
        }
    });

    $.bind('initReady', function () {
        $.registerChatCommand('./custom/botquoteCommand.js', 'botquote', 1);
    });
})();

…a pair of parentheses? THAT’S what was missing?

Well, thanks! It works now. Now back to the drawing board to find a way to actually do what this was all in service of, which this and !chat ended up being useless for. Ho hum

yup the joys of using VS Code it told me the issue :slight_smile: