This repository has been archived on 2024-10-31. You can view files and clone it, but cannot push or open issues or pull requests.
Files
ShareX-Upload-Server/bot/commands/deleteFile.js
2021-08-18 00:12:37 -07:00

18 lines
689 B
JavaScript

const fs = require('fs');
module.exports = {
command: 'df',
description: 'Delete a file from your webserver (https://{domain}/{fileName})',
syntax: '{PREFIX}df [fileName]',
execute: async (_this, msg, args) => {
if (!args.join(' ')) return msg.channel.createMessage('No arguments were given');
const fileName = args.join(' ');
const filesDir = `${__dirname}/../../server/uploads`;
fs.unlink(`${filesDir}/${fileName}`, err => {
err
? msg.channel.createMessage(`Error deleting file: ${fileName}\n${err}`)
: msg.channel.createMessage(`Successfully Deleted File: ${fileName}`);
});
},
};