2020-05-11 20:34:11 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const cleverbot = require('cleverbot-free');
|
2020-05-11 20:58:28 +02:00
|
|
|
let conversation = {};
|
2020-05-11 20:34:11 +02:00
|
|
|
|
|
|
|
class CleverBotCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('CleverBot', {
|
|
|
|
aliases: ['CleverBot', 'cb'],
|
|
|
|
category: 'fun',
|
|
|
|
clientPermissions: ['SEND_MESSAGES', 'ATTACH_FILES'],
|
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'message',
|
|
|
|
type: 'string',
|
|
|
|
prompt: {
|
|
|
|
start: 'What do you want to say to cleverbot?'
|
|
|
|
},
|
|
|
|
match: 'rest'
|
|
|
|
},
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Talk to cleverbot!',
|
2020-05-11 20:58:28 +02:00
|
|
|
usage: '[message]',
|
|
|
|
examples: ['Hello']
|
2020-05-11 20:34:11 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2020-06-15 17:56:51 +02:00
|
|
|
let loadingmsg = await message.channel.send('Processing! <a:loadingmin:527579785212329984>');
|
2020-05-11 20:58:28 +02:00
|
|
|
if (!conversation[message.guild.id]) conversation[message.guild.id] = [];
|
|
|
|
|
|
|
|
if (!conversation[0]) {
|
|
|
|
cleverbot(args.message).then(response => {
|
|
|
|
conversation[message.guild.id].push(args.message);
|
|
|
|
conversation[message.guild.id].push(response);
|
2020-07-16 09:22:39 +02:00
|
|
|
return message.channel.send(response)
|
|
|
|
.then(() => {
|
|
|
|
loadingmsg.delete();
|
|
|
|
});
|
2020-05-11 20:58:28 +02:00
|
|
|
});
|
|
|
|
} else {
|
|
|
|
cleverbot(args.message, conversation[message.guild.id]).then(response => {
|
|
|
|
conversation[message.guild.id].push(args.message);
|
|
|
|
conversation[message.guild.id].push(response);
|
2020-07-16 09:22:39 +02:00
|
|
|
return message.channel.send(response)
|
|
|
|
.then(() => {
|
|
|
|
loadingmsg.delete();
|
|
|
|
});
|
2020-05-11 20:58:28 +02:00
|
|
|
});
|
|
|
|
}
|
|
|
|
console.log(conversation);
|
2020-05-11 20:34:11 +02:00
|
|
|
}
|
|
|
|
}
|
|
|
|
module.exports = CleverBotCommand;
|