Make webhook a part of client

This commit is contained in:
Daniel Odendahl Jr
2018-08-29 23:53:42 +00:00
parent b923731f01
commit 42ca43e1ba
4 changed files with 8 additions and 9 deletions
+2 -6
View File
@@ -1,6 +1,4 @@
const Command = require('../../structures/Command');
const request = require('node-superfetch');
const { WEBHOOK_ID, WEBHOOK_TOKEN } = process.env;
module.exports = class WebhookCommand extends Command {
constructor(client) {
@@ -9,7 +7,7 @@ module.exports = class WebhookCommand extends Command {
aliases: ['rin', 'rin-say'],
group: 'text-edit',
memberName: 'webhook',
description: 'Posts a message to the webhook defined in your `process.env`.',
description: 'Posts a message to the webhook defined in the bot owner\'s `process.env`.',
details: 'Only the bot owner(s) may use this command.',
ownerOnly: true,
clientPermissions: ['MANAGE_MESSAGES'],
@@ -26,9 +24,7 @@ module.exports = class WebhookCommand extends Command {
async run(msg, { content }) {
try {
if (msg.channel.type === 'text' && msg.deletable) await msg.delete();
await request
.post(`https://discordapp.com/api/webhooks/${WEBHOOK_ID}/${WEBHOOK_TOKEN}`)
.send({ content });
await this.client.webhook.send(content);
return null;
} catch (err) {
return msg.reply(`Oh no, an error occurred: \`${err.message}\`. Try again later!`);