mirror of
https://github.com/arthur-pbty/xiao.git
synced 2026-06-24 14:19:56 +02:00
Add some stuff
This commit is contained in:
@@ -0,0 +1,41 @@
|
||||
const { Command } = require('discord.js-commando');
|
||||
const snekfetch = require('snekfetch');
|
||||
const { CLEVERBOT_KEY } = process.env;
|
||||
|
||||
module.exports = class CleverbotCommand extends Command {
|
||||
constructor(client) {
|
||||
super(client, {
|
||||
name: 'cleverbot',
|
||||
aliases: ['clevs'],
|
||||
group: 'other',
|
||||
memberName: 'cleverbot',
|
||||
description: 'Talk to Cleverbot!',
|
||||
ownerOnly: true,
|
||||
args: [
|
||||
{
|
||||
key: 'message',
|
||||
prompt: 'What do you want to say to Cleverbot?',
|
||||
type: 'string'
|
||||
}
|
||||
]
|
||||
});
|
||||
|
||||
this.convos = new Map();
|
||||
}
|
||||
|
||||
async run(msg, { message }) {
|
||||
try {
|
||||
const { body } = await snekfetch
|
||||
.get('https://www.cleverbot.com/getreply')
|
||||
.query({
|
||||
key: CLEVERBOT_KEY,
|
||||
cs: this.convos.get(msg.channel.id),
|
||||
input: message
|
||||
});
|
||||
this.convos.set(msg.channel.id, body.cs);
|
||||
return msg.reply(body.output);
|
||||
} catch (err) {
|
||||
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
|
||||
}
|
||||
}
|
||||
};
|
||||
Reference in New Issue
Block a user