fojas / cleverbot-node

Cleverbot client in node.js
MIT License
62 stars 33 forks source link

params is not defined #23

Closed generalmd2 closed 7 years ago

generalmd2 commented 7 years ago

Hello,

I need help, this I am creating a bot for discordapp but i have one erreur :

I present my code to test :

var fs = require('fs'); var Cleverbot = require('cleverbot-node'); const clever = new Cleverbot('API','KEY'); client.on('message', function(message){ if(message.content.startsWith('bonjour')){ console.log('Received message: ' + message); Cleverbot.prepare(function(){ clever.write(message, function (response) { client.sendMessage(message.channel, response.message); console.log('Retourned response: ' + response.message); }); }); } });

I am sorry but I am bad in english, because i speak French. I am used Google Translate, sorry. Thank you for your answers in advance.

fojas commented 7 years ago

It appears to be a bug in my code and yours. That chunk of code is for encoding JS Objects into URL parameters. It appears as though my code thinks it knows how to handle nested attributes. Since the message that is passed into clever.write is supposed to be a string, I probably don't need to worry about nested object attributes.

For your code, it seems like you should be passing in message.content to the clever.write method.