Add some stuff

This commit is contained in:
Daniel Odendahl Jr
2017-11-03 23:03:22 +00:00
parent 9ff49e7cb7
commit 771e1f51f5
3 changed files with 76 additions and 1 deletions
+41
View File
@@ -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!`);
}
}
};
+34
View File
@@ -0,0 +1,34 @@
const { Command } = require('discord.js-commando');
const snekfetch = require('snekfetch');
const { WEBHOOK_URL } = process.env;
module.exports = class WebhookCommand extends Command {
constructor(client) {
super(client, {
name: 'webhook',
aliases: ['rin', 'rin-say'],
group: 'text-edit',
memberName: 'webhook',
description: 'Posts a message to the webhook defined in your `process.env`.',
ownerOnly: true,
clientPermissions: ['MANAGE_MESSAGES'],
args: [
{
key: 'content',
prompt: 'What text would you like the webhook to say?',
type: 'string'
}
]
});
}
async run(msg, { content }) {
if (msg.channel.type === 'text') await msg.delete();
try {
await snekfetch.post(WEBHOOK_URL).send({ content });
return null;
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};
+1 -1
View File
@@ -1,6 +1,6 @@
{
"name": "xiaobot",
"version": "51.3.3",
"version": "51.4.0",
"description": "Your personal server companion.",
"main": "XiaoBot.js",
"scripts": {