Adding Twitch Emotes to Discord via Keywords

v239
emotes
discord
commands

#1

Hello everyone!

With the release of 2.3.9, it allows us to upload files from our bot to discord. If you’ve ever been in the PhantomBot Discord channel, you might know that if you type in (generally) any Twitch emote, the ZTVBot will post an image of said emote.

Here’s a guide on adding that to your bot!

Technically, this is two guides depending on whether or not you want twitch prime emotes included.

Before starting either tutorial, be sure to make a backup of your bot. I will help with errors, but I am not responsible for you breaking your bot.

Adding all emotes (EXCLUDES PRIME EMOTES)

First things first, download the following file:

emotes_no_prime.zip (890.5 KB)

Extract the contents of the zip (it should be an ‘emotes’ folder) to the base folder for your bot (It should be along side the config, scripts, logs, web, etc folders)

Now, open up \scripts\discord\handlers\keywordHandler.js and scroll to the very bottom until you see:

/**
 * @event initReady
 */
$.bind('initReady', function() {
    if ($.bot.isModuleEnabled('./discord/handlers/keywordHandler.js')) {
        $.discord.registerCommand('./discord/handlers/keywordHandler.js', 'keyword', 1);
        $.discord.registerSubCommand('keyword', 'add', 1);
        $.discord.registerSubCommand('keyword', 'edit', 1);
        $.discord.registerSubCommand('keyword', 'remove', 1);
		addKeywords();
        // $.unbind('initReady'); Needed or not?
    }
});

Replace from the START OF THE COMMENT (which is this: /**) to THE END OF THE FILE:

/**
 * @event initReady
 */
$.bind('initReady', function() {
    if ($.bot.isModuleEnabled('./discord/handlers/keywordHandler.js')) {
        $.discord.registerCommand('./discord/handlers/keywordHandler.js', 'keyword', 1);
        $.discord.registerSubCommand('keyword', 'add', 1);
        $.discord.registerSubCommand('keyword', 'edit', 1);
        $.discord.registerSubCommand('keyword', 'remove', 1);
		addKeywords();
        // $.unbind('initReady'); Needed or not?
    }
});
function addKeywords() {
	var emotes = ['batchest', 'supervinlin', 'bcwarrior', 'thetarfu', 'osfrog', 'mcat', 'mikehogu', 'cheffrank',
				  'ssssss', 'hotpokket', 'kapow', 'kreygasm', 'uwot', 'theringer', 'pogchamp', 'primeme', 'brokeback',
				  'seemsgood', 'dududu', 'pipehype', 'brainslug', 'kappapride', 'twitchvotes', 'mau5', 'kevinturtle',
				  'babyrage', 'poooound', 'entropywins', 'voteyea', 'gingerpower', 'keepo', 'datsheffy', 'elegiggle',
				  'heyguys', 'tehepelo', 'arsonnosexy', 'frankerz', 'ninjagrumpy', 'theilluminati', 'tbtacoprops',
				  'strawbeary', 'wholewheat', 'jebaited', 'tinyface', 'partytime', 'punoko', 'squid1', 'bigphish',
				  'argieb8', 'kappaclaus', 'coolcat', 'opieop', 'wtruck', 'joncarnage', 'inuyoface', 'grammarking',
				  'jkanstyle', 'tbtacobag', 'pjsugar', 'itsboshytime', 'carlsmile', 'permasmug', 'copythis', 'kappa',
				  'blargnaut', 'twitchraid', 'amptroppunch', 'youdontsay', 'squid3', 'kippa', 'kappu', 'squid2', 'squid4',
				  'punchtrees', 'dxcat', 'youwhy', 'futureman', 'mvgame', 'ralpherz', 'praiseit', 'twitchlit', 'peopleschamp',
				  'ritzmitz', 'daesuppy', 'hscheers', 'anele', 'thething', 'rlytho', 'notatk', 'ohmydog', 'vohiyo', 'hassanchop',
				  'coolstorybob', 'smorc', 'optimizeprime', 'koncha', 'thunbeast', 'kappaross', 'unsane', 'dbstyle', 'stinkycheese',
				  'onehand', 'toospicy', 'hsvoid', 'freakinstinkin', 'mrdestructoid', 'picomause', 'notlikethis', 'failfish',
				  'giveplz', 'funrun', 'rulefive', 'begwan', 'tbangel', 'sobayed', 'blessrng', 'residentsleeper', 'darkmode',
				  'panicbasket', 'dogface', 'tf2john', 'sabaping', '4head', 'shadylulu', 'prchase', 'pjsalt', 'biblethump',
				  'dendiface', 'twitchrpg', 'unclenox', 'imglitch', 'takenrg', 'asianglow', 'wutface', 'corgiderp', 'tearglove',
				  'shazbotstix', 'smoocherz', 'hassaanchop', 'bleedpurple', 'lul', 'tpcrunchyroll', 'humblelife', 'nomnom',
				  'twitchunity', 'budstar', 'vaultboy', 'powerupl', 'trihard', 'thankegg', 'arigatonas', 'stonelightning',
				  'tbcrunchy', 'quaddamage', 'pmstwin', 'ripepperonis', 'votenay', 'bloodtrail', 'bjblazkowicz', 'ossloth',
				  'morphintime', 'powerupr', 'pastathat', 'curselit', 'fungineer', 'minglee', 'oskomodo', 'cmonbruh',
				  'doritoschip', 'crreamawk'
	];
	var i;
	$.inidb.setAutoCommit(false);
	for (i in emotes) {
		$.inidb.set('discordKeywords', emotes[i], '(file emotes/' + emotes[i] + '.png)');
	}
	$.inidb.setAutoCommit(true);
}
})();

Now save the file. Run your bot (ONCE) and then close it after it has finished loading (I’d wait until it says "BotName ready! in the console).

Go back into the keywordHandler, and undo the changes you just did. If you don’t know what to remove, or cannot undo, copy and paste the following like you did before:

/**
* @event initReady
*/
$.bind('initReady', function() {
    if ($.bot.isModuleEnabled('./discord/handlers/keywordHandler.js')) {
        $.discord.registerCommand('./discord/handlers/keywordHandler.js', 'keyword', 1);
        $.discord.registerSubCommand('keyword', 'add', 1);
        $.discord.registerSubCommand('keyword', 'edit', 1);
        $.discord.registerSubCommand('keyword', 'remove', 1);
        addKeywords();
        // $.unbind('initReady'); Needed or not?
        }
    });

})();

Once again, save, and run your bot. You should now be able to use the emotes in discord. Note that it will not replace your text with an emote, but instead have your bot upload one.

Adding all emotes (INCLUDES PRIME EMOTES)

First things first, download the following file:

emotes_with_prime.zip (995.2 KB)

Extract the contents of the zip (it should be an ‘emotes’ folder) to the base folder for your bot (It should be along side the config, scripts, logs, web, etc folders)

Now, open up \scripts\discord\handlers\keywordHandler.js and scroll to the very bottom until you see:

/**
 * @event initReady
 */
$.bind('initReady', function() {
    if ($.bot.isModuleEnabled('./discord/handlers/keywordHandler.js')) {
        $.discord.registerCommand('./discord/handlers/keywordHandler.js', 'keyword', 1);
        $.discord.registerSubCommand('keyword', 'add', 1);
        $.discord.registerSubCommand('keyword', 'edit', 1);
        $.discord.registerSubCommand('keyword', 'remove', 1);
		addKeywords();
        // $.unbind('initReady'); Needed or not?
    }
});

Replace from the START OF THE COMMENT (which is this: /**) to THE END OF THE FILE:

/**
 * @event initReady
 */
$.bind('initReady', function() {
    if ($.bot.isModuleEnabled('./discord/handlers/keywordHandler.js')) {
        $.discord.registerCommand('./discord/handlers/keywordHandler.js', 'keyword', 1);
        $.discord.registerSubCommand('keyword', 'add', 1);
        $.discord.registerSubCommand('keyword', 'edit', 1);
        $.discord.registerSubCommand('keyword', 'remove', 1);
		addKeywords();
        // $.unbind('initReady'); Needed or not?
    }
});
function addKeywords() {
	var emotes = ['4head', 'amptroppunch', 'anele', 'argieb8', 'arigatonas', 'arsonnosexy', 'asianglow',
				  'babyrage', 'bagofmemes', 'batchest', 'bcwarrior', 'begwan', 'biblethump', 'bigbrother',
				  'bigphish', 'bjblazkowicz', 'blargnaut', 'bleedpurple', 'blessrng', 'bloodtrail',
				  'brainslug', 'brokeback', 'buddhabar', 'budstar', 'carlsmile', 'cheffrank', 'clappy',
				  'clappyderp', 'clappyhype', 'cmonbruh', 'coolcat', 'coolstorybob', 'copythis', 'corgiderp',
				  'crreamawk', 'curselit', 'daesuppy', 'dansgame', 'darkmode', 'datsheffy', 'dbstyle',
				  'dendiface', 'dogface', 'doritoschip', 'dududu', 'dxcat', 'elegiggle', 'entropywins', 'failfish',
				  'flipthis', 'frankerz', 'freakinstinkin', 'fungineer', 'funrun', 'futureman', 'gingerpower',
				  'giveplz', 'grammarking', 'hassaanchop', 'hassanchop', 'heyguys', 'hotpokket', 'hscheers', 'hslight',
				  'hsvoid', 'hswp', 'humblelife', 'imglitch', 'inuyoface', 'itsboshytime', 'jebaited', 'jkanstyle',
				  'joncarnage', 'kapow', 'kappa', 'kappaclaus', 'kappahd', 'kappapride', 'kappaross', 'kappawealth',
				  'kappu', 'keepo', 'kevinturtle', 'kippa', 'koncha', 'kreygasm', 'lul', 'mau5', 'mcat', 'mikehogu',
				  'mindmanners', 'minglee', 'minik', 'morphintime', 'mrdestructoid', 'mvgame', 'ninjagrumpy', 'nomnom',
				  'notatk', 'notlikethis', 'ohmydog', 'onehand', 'opieop', 'optimizeprime', 'osfrog', 'oskomodo',
				  'ossloth', 'panicbasket', 'panicvis', 'partypopper', 'partytime', 'pastathat', 'peopleschamp', 
				  'permasmug', 'picomause', 'pipehype', 'pjsalt', 'pjsugar', 'pmstwin', 'pogchamp', 'poooound',
				  'powerupl', 'powerupr', 'praiseit', 'prchase', 'primeme', 'primerlytho', 'primeuwot',
				  'primeyoudontsay', 'punchtrees', 'punoko', 'quaddamage', 'raccattack', 'ralpherz', 'redcoat',
				  'residentsleeper', 'ripepperonis', 'ritzmitz', 'rlytho', 'rulefive', 'sabaping', 'scaredycat',
				  'seemsgood', 'shadylulu', 'shazbotstix', 'smoocherz', 'smorc', 'sobayed', 'soonerlater', 'squid1',
				  'squid2', 'squid3', 'squid4', 'ssssss', 'stinkycheese', 'stonelightning', 'strawbeary',
				  'supervinlin', 'swiftrage', 'tablehere', 'takenrg', 'tbangel', 'tbcrunchy', 'tbtacobag',
				  'tbtacoprops', 'tearglove', 'tehepelo', 'tf2john', 'thankegg', 'theilluminati', 'theringer',
				  'thetarfu', 'thething', 'thunbeast', 'tinyface', 'toospicy', 'tpcrunchyroll', 'trihard',
				  'ttours', 'twitchcop', 'twitchlit', 'twitchraid', 'twitchrpg', 'twitchunity', 'twitchvotes',
				  'unclenox', 'unsane', 'uwot', 'vaultboy', 'vohiyo', 'votenay', 'voteyea', 'wholewheat', 'wtruck',
				  'wutface', 'youdontsay', 'youwhy'
	];
	var i;
	$.inidb.setAutoCommit(false);
	for (i in emotes) {
		$.inidb.set('discordKeywords', emotes[i], '(file emotes/' + emotes[i] + '.png)');
	}
	$.inidb.setAutoCommit(true);
}
})();

Now save the file. Run your bot (ONCE) and then close it after it has finished loading (I’d wait until it says "BotName ready! in the console).

Go back into the keywordHandler, and undo the changes you just did. If you don’t know what to remove, or cannot undo, copy and paste the following like you did before:

/**
* @event initReady
*/
$.bind('initReady', function() {
    if ($.bot.isModuleEnabled('./discord/handlers/keywordHandler.js')) {
        $.discord.registerCommand('./discord/handlers/keywordHandler.js', 'keyword', 1);
        $.discord.registerSubCommand('keyword', 'add', 1);
        $.discord.registerSubCommand('keyword', 'edit', 1);
        $.discord.registerSubCommand('keyword', 'remove', 1);
        addKeywords();
        // $.unbind('initReady'); Needed or not?
        }
    });

})();

Once again, save, and run your bot. You should now be able to use the emotes in discord. Note that it will not replace your text with an emote, but instead have your bot upload one.

Conclusion

If you have any issues with adding the emotes, please post below. I’ll do what I can to help, but remember, I’m not superman.

Here’s what it should look like when you’re said and done:

emoteexample


Bot can no longer upload to discord
#2

Almost completely unrelated, but where we do upload files normally? I didn’t see this in the patch notes, how do we set this up for individual images if we want?


#3

So the (file) tag will start at the root of your bot folder, you have to reference the file from there. That’s why I placed everything in the /emotes/ folder at the root.
As far as I was told, any outgoing message from the bot can use the tag. I’ve personally tested it in keywords and custom commands, but not a script.

Just note though, that any text placed with the file upload usually goes poof, so if you want text before it you’d probably use a custom script and put something like:

$.discord.say('Hey guys welcome to the server, read the following image to learn what we're about');
$.discord.say('(file welcome.png)');

Which, should print the text above the image.

And I’m not sure why this wasn’t in the notes anywhere


#4

Cool, thanks. Is it just PNGs? Would it support gifs? Mostly want it for single images as responses, don’t need to script anything into it.


#5

I’ve personally only tested a jpg and a png… I’d assume any file discord accepts will work?


#6

Cool, will play around this evening, thanks. :slight_smile:


#7

I know this sounds like a given, but make sure to have the Discord KeywordHandler enabled. Took me 30 minutes to realize it wasn’t on and needed to be. PJSalt.