Jump to content
Frequently Asked Questions
  • Are you not able to open the client? Try following our getting started guide
  • Still not working? Try downloading and running JarFix
  • Help! My bot doesn't do anything! Enable fresh start in client settings and restart the client
  • How to purchase with PayPal/OSRS/Crypto gold? You can purchase vouchers from other users
  • ezpz webhooks & a little bit of thought about automating error reporting in scripts.


    camelCase

    Recommended Posts

    discord webhooks provide a nice way to monitor your bots progress without having to watch your bots, you can get notifications on big loot drops, big trades, notifications for scouters etc.

    this code is written with java 8 & GSON so i believe it will work fine on the SDN

    here is some code i wrote last night thats very plug and play so if you want to use them in your scripts you dont have to investigate how the webhooks really work.

    https://github.com/Amoz3/Discord-Webhooks 

    WebHookPojo contains an array of EmbedPojos which contains an array of FieldPojos, the WebHook is transformed into a json string with GSON which is then sent to your provided url. basically explains it all

     

    heres how to use this in a script. (note that discord rate limits webhooks to 30 msgs per minute, so be sure to not place webhooks anywhere they will spam you)

    FieldPojo lvlField = new FieldPojo("lvl", "1", true);
    FieldPojo[] fields = new FieldPojo[]{lvlField};
    
    EmbedPojo embedPojo = new EmbedPojo("test script", "", fields);
    EmbedPojo[] embeds = new EmbedPojo[]{embedPojo};
    
    WebHookPojo webhook = new WebHookPojo(embeds);
    
    String url = "put ur webhook url here.";
    @Override
    public int onLoop() {
        lvlField.setValue(String.valueOf(Skills.getRealLevel(Skill.HITPOINTS)));
        try {
            WebHookUtil.execute(url, webhook);
        } catch (IOException e) {
            throw new RuntimeException(e);
        }
        return 4000;
    
    }

    that code produces this webhook.qv737ni.png

    in the github readme there is more detailed code of a prettier webhook, to change the name and avatar of your webhook, you can either do that directly in discord or use the username and avatar_url strings in webhookpojo. the color of the embed bar is in EmbedPojo.

     

    now for a little thinking about automating error reports.

    problem: a game update or just lack of testing has lead to a problem in your script, people are using it but are not reporting the bug, maybe they are baby sitting and can manually fix the bug with a restart or game interaction, maybe they dont know how to report, dont care too or even worse they do report it but all the information they give you is "scripts broken, doesnt work :/"

     

    solution ive been thinking about is having logic in your script to detect if something has gone wrong / script is stuck, then sending useful information via a webhook, eg. script state, runtime, location whatever you think would be relevant. maybe even the whole logs file because webhooks do support files, at the time of writing this my code does not however.

     

    methods of detecting logic failures ive come up with are:

    tracking amount of times login solver has started, resetting or -1 every time a break is activated. this would be for instances where say an NPC cant be found and your script just idles until it is found. this might produce alot of false positives for users with terrible connections though.

     

    for scripts that do quests, a timer connected to the quest that is activated when that quests varp is changed, then once that timer reaches however long you would expect that quest to take & the varp isnt at the completion value, send error report, this method could also be applied to other scripts that you have some way of checking the state, eg. if you've been trying to cook all the food in your inventory for like 6 minutes, somethings probably busted.

     

    id really appreciate feedback on that & any other general methods of detecting bugs by the script itself

     

     

     

     

    Link to comment
    Share on other sites

    Create an account or sign in to comment

    You need to be a member in order to leave a comment

    Create an account

    Sign up for a new account in our community. It's easy!

    Register a new account

    Sign in

    Already have an account? Sign in here.

    Sign In Now
    ×
    ×
    • Create New...

    Important Information

    We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.