chit-chatter
v1.1.47
Published
This package aims to making producing Discord(and not only it) chatbots much easier
Downloads
68
Readme
Chit-chatter
Installation
To install the package run:
npm i chit-chatter
or
npm install chit-chatter
Usage
Never delete (and don't forget to add to your code) responses object and dia object , it can't work without it! Also, use it as a first parameter when calling add() First require chit-chatter
const chat = require('chit-chatter')
This repository already got a sample bot in it which you can use after entering your bot's token into :point_down:
bot.login('Your token here')
at the end of the main.js file, also add :point_down:
const {
Client
} = require('discord.js');
at the very top
and
run
npm install discord.js
in the terminal
In order to add a simple response: call (use)
chat.add(object, array, expression, array)
function in main.js(if you are modifying the sample bot) or into your code(if you are building your own) using this parameters: object for storing responses(responses) array of possible user messages that the bot will react to (array), expression which will be set to this kind of messages(string), array of possible responses(array)
then
chat.train()
after it inside message listener
chat.classify(string)
to get the expression from the message for further use(string -> message) In order to add a dialog: call (use)
chat.chain(array, expression)
function in main.js(if you are modifying the sample bot) or into your code(if you are building your own) using parameters listed here: array of messages in format user-bot-user-bot and so on...(array), expression which will be set to this kind of messages(string), But remember: You will also need to call add() method with all the messages you use in your dialog and mark it's expression the same way but don't add last parameter (responses)
and call
chat.listenChain(expression, message)
to handle the dialogues(it sends the messages itself!).
Easy way
You can instead do this:
bot.on('ready', function(){chat.ready(bot, 'Activity for the bot you chose', 'Second part of activity')})
bot.on('message', function(message){chat.listen(bot, responses, message)})
##Other methods
chat.random(array)
to pick a random element of an array(it's needed when replying with one of the responses)
chat.testing()
to check if it works(if it does it will log 'Success!' to the console)