Hi to all, I am also someone new to PhantomBot or even botting in Twitch as a whole so I can understand the frustration of people trying to find out what to do your first custom script. (Not those you customize in the commands panel but those you literally script yourself.)
I believe, nonetheless, this still does requires the following:
- Notepad++ (Recommended for non-IDE users)
This also doesn’t teach you the entirety that you would need for whatever you plan to do. It’s literally the basics or something to start you off like a template.
Create a script file as follows (PhantomBot/scripts/commands) (I haven’t try it out but anywhere in the scripts folder should be fine.)
Copy the content in the following link to your new command.js file: (My example, helloWorld.js)
Take a look at the different points or change the following to fit your script:
- (a) Ensure that you change that to the command you wish to use in the chat (e.g. !command)
- (b)As explained in the comments, the ‘if else’ is unnecessary unless you want to use for arguments to check for options and stuff
- ©Change the ‘./commands/helloWorld.js’ to the directory of your command. (E.g. your script might be a game so you placed it in the game, then that would be ‘./games/yourGame.js’)
- (Still c)The final ‘helloworld’ ensure it’s the same as the one in (a)
Make sure you save your script and run the bot.
Check that there is no error in the bot console.(Script error can be seen here as well: ./logs/core-error/DD-MM-YYYY.txt)
Go to your channel and try your new script
Doesn’t look the best but it WORKS!
Hope this tutorial works for you. (Using PB 2.3.8)
Do note that there are other things to be concerned of like how to get the script to be seen in the disable modules page.
I can do those up but at least for now, this should give you an easier time starting out on something.
I am still learning too so I hope I can get your feedback on this.