Files
xiao/commands/text-edit/webhook.js
T
Daniel Odendahl Jr b6afded306 Updates
2017-11-09 00:02:59 +00:00

35 lines
902 B
JavaScript

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: 'message',
prompt: 'What text would you like the webhook to say?',
type: 'string'
}
]
});
}
async run(msg, { message }) {
if (msg.channel.type === 'text') await msg.delete();
try {
await snekfetch.post(WEBHOOK_URL).send({ content: message });
return null;
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);
}
}
};