-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
132 lines (131 loc) · 4.2 KB
/
index.js
File metadata and controls
132 lines (131 loc) · 4.2 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
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
let Discord = require("discord.js")
let axios = require("axios")
let fs = require("fs")
let Bot = new Discord.Client()
let prefix = "!"
const util = require('util')
const exec = util.promisify(require('child_process').exec)
let Embed = function(Des, fields) {
const Emb = new Discord.MessageEmbed();
Emb.setDescription(Des)
Emb.setColor(0x3498DB)
Emb.setFooter(Bot.user.username, Bot.user.displayAvatarURL())
if (fields) {
Emb.addFields(fields)
}
Emb.setTitle("coronavirus bot")
Emb.setTimestamp()
return Emb
}
function RandomString(length) {
var result = ''
var characters = 'ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz'
var charactersLength = characters.length
for ( var i = 0; i < length; i++ ) {
result += characters.charAt(Math.floor(Math.random() * charactersLength))
}
return result
}
let Commands = {}
function addcommand(name, callback, DmsOnly) {
Commands[prefix + name] = {callback: callback, DmsOnly: DmsOnly || false}
}
let Filter = function(name) {
const ValueName = name
return function(ValName) {
if (ValName === ValueName) {
return false
} else {
return true
}
}
}
Bot.on("message", function(message) {
const args = message.content.split(" ");
const Sender = message.author.id
const Mention = message.mentions.users.first()
if (args[0].startsWith(prefix)) {
const CommandName = args[0]
if (Commands[CommandName]) {
if (message.channel.type !== (Commands[CommandName].DmsOnly && "dm" || "text")) return
if (Mention && Mention.bot) {
message.channel.send(Embed("The user is a bot"))
return
}
try {
Commands[CommandName].callback(message, args.filter(Filter(CommandName)))
}
catch (err) {
message.channel.send(Embed("There was an error in the command dm stroketon about it"))
err.name = `${CommandName}`
console.log(`${err.stack}`)
}
}
}
})
async function Obfuscate(Script) {
let FileName = RandomString(10)
let File = `./${FileName}.lua`
fs.writeFileSync(File, Script)
try {
await exec(`lua ZeroTolerance.lua ${File}`)
var Results = fs.readFileSync("./" + FileName + "-obfuscated.lua", {encoding: "utf8"})
fs.unlinkSync(File)
} catch(err) {
fs.unlinkSync(File)
throw err
}
return Results, FileName
}
String.prototype.replaceAll = function (find, replace) {
var str = this.toString();
return str.replace(new RegExp(find.replace(/[-\/\\^$*+?.()|[\]{}]/g, '\\$&'), 'g'), replace);
};
function GetServer() {
return Bot.guilds.cache.find(guild => guild.id === "703446036231749722")
}
addcommand("obfuscate", async function(msg, args) {
if (!GetServer().member(msg.author.id).roles.cache.has("703468579223240753")) {
msg.channel.send(Embed("You are not whitelisted"))
return
}
if (!args[0]) {
msg.channel.send(Embed("Please submit a codeblock or file"))
return
}
if (!msg.attachments.first()) {
console.log("a")
var Script = args.join(" ")
if (Script.split("\n").length !== 1) {
let Lines = Script.split("\n")
if (Lines[0].search("```") == -1) {
return
}
Lines.splice(0, 1)
Lines.pop()
Script = Lines.join("\n")
}
} else {
var Attachment = msg.attachments.first()
let Response = await axios({
method: "get",
url: Attachment.url
})
Script = Response.data
}
try {
msg.channel.startTyping()
var a, b = await Obfuscate(Script)
await msg.channel.send({files: [{
attachment: __dirname + "\\" + b + "-obfuscated.lua",
name: b + "-obfuscated.lua"
}]})
fs.unlinkSync("./" + b + "-obfuscated.lua")
msg.channel.stopTyping()
} catch (err) {
let aaa = err.toString().split("\n")[1]
msg.channel.send(Embed(`Syntax error\n\`\`\`${aaa}\`\`\``))
msg.channel.stopTyping()
}
}, true)
Bot.login("")