Discord Logging


#1

So with the help of @JustAlixe I have made a script for logging various functionalities in twitch chat. The question I have is how do I make it log when a mod is added/removed?

(function() {
    $.bind('ircPrivateMessage', function(event) {
        var sender = event.getSender().toLowerCase(),
            message = event.getMessage().toLowerCase();
            modLogs = $.getSetIniDbBoolean('discordSettings', 'modLogs', false),
            modLogChannel = $.getSetIniDbString('discordSettings', 'modLogChannel', '');

        if (!modLogs) {
            return;
        }
        if (message.indexOf('slow') !== -1 && message.indexOf('mode') !== -1) { 
            if (message.indexOf('now') !== -1) {
                var target = String(message).replace('this room is now in slow mode.', '').replace('You may send messages every', '');

                $.discordAPI.sendMessageEmbed(modLogChannel, 'red', 'Slowmode has been enabled for' + target);
            }

            if (message.indexOf('longer') !== -1) {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'green', 'Slowmode has been disabled.');
            }
        }

        if (message.indexOf('subscribers-only') !== -1 && message.indexOf('mode') !== -1) { 
            if (message.indexOf('now') !== -1) {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'red', 'Subscribers Only has been enabled.');
            }

            if (message.indexOf('longer') !== -1) {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'green', 'Subscribers Only has been disabled.');
            }
        }

        if (message.indexOf('followers-only') !== -1 && message.indexOf('mode') !== -1) { 
            if (message.indexOf('now') !== -1) {
                var target = String(message).replace('this room is now in', '').replace('followers-only mode', '');

                $.discordAPI.sendMessageEmbed(modLogChannel, 'red', 'Followers Only has been enabled for' + target);
            }

            if (message.indexOf('longer') !== -1) {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'green', 'Followers Only has been disabled.');
            }
        }

        if (message.indexOf('r9k') !== -1 && message.indexOf('mode') !== -1) { 
            if (message.indexOf('now') !== -1) {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'red', 'R9K has been enabled.');
            }

            if (message.indexOf('longer') !== -1) {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'green', 'R9K has been disabled.');
            }
        }

        if (message.indexOf('hosting') !== -1) {
            var target = String(message).replace('now hosting', '');

            if (target.equalsIgnoreCase('-')) {
                return;
            } else {
                $.discordAPI.sendMessageEmbed(modLogChannel, 'green', 'Now Hosting' + target);
            }
        }
		
        if (message.indexOf('moderator') !== -1) {
            if (message.indexOf('added') !== -1) {
                var target = String(message).replace('You have added', '').replace('as a moderator of this channel.', '');

                $.discordAPI.sendMessageEmbed(modLogChannel, 'red', target + 'has been added as a moderator of this channel');
            }

            if (message.indexOf('removed') !== -1) {
                var target = String(message).replace('You have added', '').replace('as a moderator of this channel.', '');

                $.discordAPI.sendMessageEmbed(modLogChannel, 'green', target + 'has been removed as a moderator of this channel');
            }
        }  		
    });
})();

The issue I have is that when i try run this I get the error:

 [03-03-2018 @ 21:07:58.466 GMT] java.io.FileNotFoundException: PhantomBot.themodguyy.pid (Permission denied)
    at java.io.FileOutputStream.open0(Native Method)
    at java.io.FileOutputStream.open(FileOutputStream.java:270)
    at java.io.FileOutputStream.<init>(FileOutputStream.java:213)
    at tv.phantombot.PhantomBot.<init>(PhantomBot.java:661)
    at tv.phantombot.PhantomBot.main(PhantomBot.java:2485)

Anyone can help me work out what ive done wrong?


#2

Cant seem to do mod the same way sorry


#3

Can it be done another way?


#4

look into the pubsub and work that out and no i cant help with that cus i have no idea how it works so dont ask me


#5

Is anyone else able to help?