2022-08-28 17:03:15 +02:00
|
|
|
import { SlashCommandBuilder } from 'discord.js';
|
2022-08-17 16:21:58 +02:00
|
|
|
import Twit from 'twit';
|
|
|
|
|
|
|
|
const { twiConsumer, twiConsumerSecret, twiToken, twiTokenSecret } = process.env;
|
|
|
|
|
|
|
|
export default {
|
|
|
|
data: new SlashCommandBuilder()
|
2022-08-28 17:22:26 +02:00
|
|
|
.setName('deletetweet')
|
2022-08-17 16:21:58 +02:00
|
|
|
.setDescription('Delete a tweet')
|
|
|
|
.addStringOption(option =>
|
|
|
|
option.setName('tweetid')
|
2022-10-31 13:13:09 +01:00
|
|
|
.setDescription('The ID of the tweet you wish to delete.')
|
2022-08-17 16:21:58 +02:00
|
|
|
.setRequired(true)),
|
2022-08-28 17:03:15 +02:00
|
|
|
category: 'owner',
|
2022-08-17 16:21:58 +02:00
|
|
|
ownerOnly: true,
|
2022-10-13 15:49:31 +02:00
|
|
|
async execute(interaction, args) {
|
2022-08-17 16:21:58 +02:00
|
|
|
await interaction.deferReply();
|
|
|
|
try {
|
|
|
|
const T = new Twit({
|
|
|
|
consumer_key: twiConsumer,
|
|
|
|
consumer_secret: twiConsumerSecret,
|
|
|
|
access_token: twiToken,
|
|
|
|
access_token_secret: twiTokenSecret,
|
|
|
|
});
|
|
|
|
|
|
|
|
T.post('statuses/destroy', {
|
2022-10-13 15:49:31 +02:00
|
|
|
id: args.tweetid,
|
2022-08-17 16:21:58 +02:00
|
|
|
});
|
2022-10-31 13:13:09 +01:00
|
|
|
return interaction.editReply('Tweet has been deleted!');
|
2022-08-17 16:21:58 +02:00
|
|
|
}
|
|
|
|
catch (err) {
|
|
|
|
console.error(err);
|
|
|
|
return interaction.editReply('Oh no, an error has occurred :(');
|
|
|
|
}
|
|
|
|
},
|
|
|
|
};
|