Files
xiao/commands/textedit/webhook.js
T
Daniel Odendahl Jr 7802bb49cb Clean-Ups
2017-05-31 04:41:01 +00:00

43 lines
1.2 KiB
JavaScript

const Command = require('../../structures/Command');
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: 'textedit',
memberName: 'webhook',
description: 'Posts a message to the webhook defined in your `process.env`.',
guildOnly: true,
ownerOnly: true,
clientPermissions: ['MANAGE_MESSAGES'],
args: [
{
key: 'content',
prompt: 'What text would you like the webhook to say?',
type: 'string'
}
]
});
}
hasPermission(msg) {
return this.client.isOwner(msg.author);
}
async run(msg, args) {
const { content } = args;
try {
msg.delete();
await snekfetch
.post(WEBHOOK_URL)
.send({ content });
return null;
} catch (err) {
return msg.say(`${err.name}: ${err.message}`);
}
}
};