2020-05-13 08:47:35 +02:00
|
|
|
const { Command } = require('discord-akairo');
|
|
|
|
const fs = require('fs');
|
|
|
|
const md5File = require('md5-file');
|
|
|
|
const ytpHash = require('../../models').ytpHash;
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class removeytpCommand extends Command {
|
|
|
|
constructor() {
|
|
|
|
super('removeytp', {
|
|
|
|
aliases: ['removeytp', 'rytp', 'ytpr'],
|
|
|
|
category: 'owner',
|
|
|
|
ownerOnly: 'true',
|
|
|
|
clientPermissions: ['SEND_MESSAGES'],
|
|
|
|
args: [
|
|
|
|
{
|
2021-03-13 18:21:33 +01:00
|
|
|
id: 'messageID',
|
2021-03-16 15:27:38 +01:00
|
|
|
type: 'bigint'
|
2020-05-13 08:47:35 +02:00
|
|
|
}
|
|
|
|
],
|
|
|
|
description: {
|
|
|
|
content: 'Delete a ytp',
|
2021-03-13 18:21:33 +01:00
|
|
|
usage: '[message id]',
|
|
|
|
examples: ['some message id']
|
2020-05-13 08:47:35 +02:00
|
|
|
}
|
|
|
|
});
|
|
|
|
}
|
|
|
|
|
|
|
|
async exec(message, args) {
|
2021-03-16 15:25:55 +01:00
|
|
|
let filepath = `./asset/ytp/userVid/${args.messageID}.mp4`;
|
|
|
|
const hash = md5File.sync(filepath);
|
2020-05-13 08:47:35 +02:00
|
|
|
const ytphash = await ytpHash.findOne({where: {hash: hash}});
|
|
|
|
|
|
|
|
if (ytphash) {
|
|
|
|
await ytpHash.destroy({where: {hash: hash}});
|
|
|
|
}
|
|
|
|
|
2021-03-16 15:25:55 +01:00
|
|
|
fs.unlinkSync(filepath);
|
2020-05-13 08:47:35 +02:00
|
|
|
return message.channel.send('Successfully removed the video.');
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = removeytpCommand;
|