forked from Sasukesense/Itachi-Uchiwa-
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathpastebin.js
More file actions
59 lines (50 loc) · 1.62 KB
/
pastebin.js
File metadata and controls
59 lines (50 loc) · 1.62 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
const PastebinAPI = require('pastebin-js');
const fs = require('fs');
const path = require('path');
module.exports = {
config: {
name: "pastebin",
version: "1.0",
author: "SANDIP",
countDown: 5,
role: 2,
shortDescription: {
en: "Upload files to pastebin and sends link"
},
longDescription: {
en: "This command allows you to upload files to pastebin and sends the link to the file."
},
category: "Utility",
guide: {
en: "To use this command, type !pastebin <filename>. The file must be located in the 'cmds' folder."
}
},
onStart: async function({ api, event, args }) {
const pastebin = new PastebinAPI({
api_dev_key: 'LFhKGk5aRuRBII5zKZbbEpQjZzboWDp9',
api_user_key: 'LFhKGk5aRuRBII5zKZbbEpQjZzboWDp9',
});
const fileName = args[0];
const filePathWithoutExtension = path.join(__dirname, '..', 'cmds', fileName);
const filePathWithExtension = path.join(__dirname, '..', 'cmds', fileName + '.js');
if (!fs.existsSync(filePathWithoutExtension) && !fs.existsSync(filePathWithExtension)) {
return api.sendMessage('File not found!', event.threadID);
}
const filePath = fs.existsSync(filePathWithoutExtension) ? filePathWithoutExtension : filePathWithExtension;
fs.readFile(filePath, 'utf8', async (err, data) => {
if (err) throw err;
const paste = await pastebin
.createPaste({
text: data,
title: fileName,
format: null,
privacy: 1,
})
.catch((error) => {
console.error(error);
});
const rawPaste = paste.replace("pastebin.com", "pastebin.com/raw");
api.sendMessage(`File uploaded to Pastebin: ${rawPaste}`, event.threadID);
});
},
}