2019-02-28 17:35:53 +01:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const fetch = require('node-fetch');
|
|
|
|
const { fbToken, fbID } = require('../../config.json');
|
|
|
|
|
|
|
|
class rfacebookCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('rfacebook', {
|
|
|
|
aliases: ['rfacebook', 'rfb'],
|
2019-03-15 17:59:16 +01:00
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
2019-02-28 17:44:09 +01:00
|
|
|
cooldown: 86400000,
|
|
|
|
ratelimit: 3,
|
2019-02-28 17:35:53 +01:00
|
|
|
args: [
|
|
|
|
{
|
|
|
|
id: 'id',
|
|
|
|
type: 'string',
|
|
|
|
match: 'rest'
|
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Post your message to the bot rfacebook page',
|
|
|
|
usage: '[text]',
|
|
|
|
examples: ['epic']
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
|
|
|
fetch(`https://graph.facebook.com/${fbID}_${args.id}?access_token=${fbToken}`, {
|
|
|
|
method: 'delete',
|
|
|
|
}).then((response) => {
|
|
|
|
return response.json();
|
|
|
|
}).then((response) => {
|
|
|
|
console.log(response.success);
|
|
|
|
if (response.success) {
|
|
|
|
return message.channel.send('Sucessfully deleted the post');
|
|
|
|
} else {
|
|
|
|
return message.channel.send('An error has occured :(');
|
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = rfacebookCommand;
|