forked from Supositware/Haha-Yes
Store the messages for future conversation
Signed-off-by: loicbersier <loic.bersier1@gmail.com>
This commit is contained in:
parent
9fc87f42be
commit
bdac7fc268
1 changed files with 22 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
const { Command } = require('discord-akairo');
|
const { Command } = require('discord-akairo');
|
||||||
const cleverbot = require('cleverbot-free');
|
const cleverbot = require('cleverbot-free');
|
||||||
|
let conversation = {};
|
||||||
|
|
||||||
class CleverBotCommand extends Command {
|
class CleverBotCommand extends Command {
|
||||||
constructor() {
|
constructor() {
|
||||||
|
@ -19,16 +20,32 @@ class CleverBotCommand extends Command {
|
||||||
],
|
],
|
||||||
description: {
|
description: {
|
||||||
content: 'Talk to cleverbot!',
|
content: 'Talk to cleverbot!',
|
||||||
usage: '',
|
usage: '[message]',
|
||||||
examples: ['']
|
examples: ['Hello']
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
async exec(message, args) {
|
async exec(message, args) {
|
||||||
|
let loadingmsg = await message.channel.send('Processing <a:loadingmin:527579785212329984>');
|
||||||
|
if (!conversation[message.guild.id]) conversation[message.guild.id] = [];
|
||||||
|
|
||||||
|
|
||||||
|
if (!conversation[0]) {
|
||||||
cleverbot(args.message).then(response => {
|
cleverbot(args.message).then(response => {
|
||||||
|
conversation[message.guild.id].push(args.message);
|
||||||
|
conversation[message.guild.id].push(response);
|
||||||
|
return message.channel.send(response);
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
cleverbot(args.message, conversation[message.guild.id]).then(response => {
|
||||||
|
conversation[message.guild.id].push(args.message);
|
||||||
|
conversation[message.guild.id].push(response);
|
||||||
return message.channel.send(response);
|
return message.channel.send(response);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
console.log(conversation);
|
||||||
|
loadingmsg.delete();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
module.exports = CleverBotCommand;
|
module.exports = CleverBotCommand;
|
Loading…
Reference in a new issue