Haha-Yes/commands/owner/rtweet.js

48 lines
1 KiB
JavaScript
Raw Permalink Normal View History

2019-02-25 05:06:33 +01:00
const { Command } = require('discord-akairo');
2019-11-25 23:42:03 +01:00
const Twit = require('twit');
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret } = require('../../config.json');
2019-02-25 05:06:33 +01:00
class rtweetCommand extends Command {
constructor() {
super('rtweet', {
aliases: ['rtweet', 'rmtweet'],
2019-02-25 19:23:38 +01:00
category: 'owner',
ownerOnly: 'true',
2019-02-25 05:06:33 +01:00
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 {
2019-11-25 23:42:03 +01:00
let T = new Twit({
2019-02-25 05:06:33 +01:00
consumer_key: twiConsumer,
consumer_secret: twiConsumerSecret,
2019-11-25 23:42:03 +01:00
access_token: twiToken,
2019-02-25 05:06:33 +01:00
access_token_secret: twiTokenSecret
});
2019-11-25 23:42:03 +01:00
T.post('statuses/destroy', {
2019-02-25 05:06:33 +01:00
id: text
});
return message.channel.send('Tweet have been deleted!');
} catch(err) {
console.error(err);
return message.channel.send('Oh no, an error has occurred :(');
2019-02-25 05:06:33 +01:00
}
}
}
module.exports = rtweetCommand;