From 84a4f4137bff35aed5d48feaa154a92e269edd30 Mon Sep 17 00:00:00 2001 From: Loic Bersier Date: Mon, 25 Feb 2019 05:06:33 +0100 Subject: [PATCH] delete a tweet --- commands/owner/rtweet.js | 49 ++++++++++++++++++++++++++++++++++++++++ 1 file changed, 49 insertions(+) create mode 100644 commands/owner/rtweet.js diff --git a/commands/owner/rtweet.js b/commands/owner/rtweet.js new file mode 100644 index 0000000..87a8e8a --- /dev/null +++ b/commands/owner/rtweet.js @@ -0,0 +1,49 @@ +const { Command } = require('discord-akairo'); +const Twitter = require('twitter-lite'); +const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret } = require('../../config.json'); + +class rtweetCommand extends Command { + constructor() { + super('rtweet', { + aliases: ['rtweet', 'rmtweet'], + category: 'general', + cooldown: 86400, + ratelimit: 1, + args: [ + { + id: 'text', + type: 'string', + match: 'rest' + } + ], + description: { + content: 'Delete a tweet', + usage: '[tweet id]', + examples: ['1099882994599383040'] + } + }); + } + + async exec(message, args) { + let text = args.text; + try { + let client = new Twitter({ + consumer_key: twiConsumer, + consumer_secret: twiConsumerSecret, + access_token_key: twiToken, + access_token_secret: twiTokenSecret + }); + + client.post('statuses/destroy', { + id: text + }); + return message.channel.send('Tweet have been deleted!'); + } catch(err) { + console.error(err); + return message.channel.send('Oh no, an error has occured :('); + } + + } +} + +module.exports = rtweetCommand; \ No newline at end of file