-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathbot.js
255 lines (240 loc) · 10.4 KB
/
bot.js
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
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
const cp = require("child_process");
// auto install dependencies
const packageJson = require("./package.json");
for (let dep of Object.keys(packageJson.dependencies)) {
try {
require.resolve(dep);
} catch (err) {
console.log(`Installing dependencies...`);
cp.execSync(`npm i`);
}
}
const { logger } = require("./utils/logger");
const fs = require("fs");
const axios = require("axios");
const path = require("path");
const admZip = require("adm-zip");
const os = require("os");
const fse = require("fs-extra");
const gitUpdate = () => {
try {
cp.execSync("git stash");
logger.info("Updater", "Git", "Pulling ...");
cp.execSync("git pull --force");
logger.info("Updater", "Git", "Pull successful.");
logger.info("Updater", "Git", "Resetting local changes...");
cp.execSync("git reset --hard");
logger.info("Updater", "Zip", "Project updated successfully.");
process.exit(0);
} catch (error) {
logger.alert(
"Updater",
"Git",
`Error updating project from Git: ${error}`
);
process.exit(0);
}
};
const manualUpdate = async () => {
try {
const headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537",
};
const res = await axios.get(
`https://github.com/Mid0aria/EpicRPGFarmBot/archive/master.zip`,
{
responseType: "arraybuffer",
headers,
}
);
const updatePath = path.resolve(__dirname, "updateCache.zip");
fs.writeFileSync(updatePath, res.data);
const zip = new admZip(updatePath);
const zipEntries = zip.getEntries();
zip.extractAllTo(os.tmpdir(), true);
const updateFolder = path.join(os.tmpdir(), zipEntries[0].entryName);
if (!fs.existsSync(updateFolder)) {
logger.alert(
"Updater",
"Zip",
"Failed To Extract Files! Please update on https://github.com/Mid0aria/EpicRPGFarmBot/"
);
}
fse.copySync(updateFolder, process.cwd(), { overwrite: true });
logger.info("Updater", "Zip", "Project updated successfully.");
process.exit(0);
} catch (error) {
logger.alert(
"Updater",
"Zip",
`Error updating project from GitHub Repo: ${error}`
);
process.exit(0);
}
};
const checkUpdate = async () => {
console.log(
chalk.blue(chalk.bold(`Updater`)),
chalk.white(`>>`),
chalk.yellow(`Checking Update`)
);
try {
const headers = {
"User-Agent":
"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/58.0.3029.110 Safari/537",
};
const response = await axios.get(
`https://raw.githubusercontent.com/Mid0aria/EpicRPGFarmBot/main/package.json`,
{
headers,
}
);
const ghVersion = response.data.version;
const version = packageJson.version;
if (ghVersion > version) {
console.log(
chalk.blue(chalk.bold("Updater")),
chalk.white(`>>`),
chalk.yellow("Please wait while the farm bot is updating...")
);
if (fs.existsSync(".git")) {
try {
cp.execSync("git --version");
logger.info("Git", "Updating with Git...");
gitUpdate();
} catch (error) {
console.log(
chalk.blue(chalk.bold("Git")),
chalk.white(`>>`),
chalk.red(
"Git is not installed on this device. Files will be updated with cache system"
)
);
await manualUpdate();
}
} else {
await manualUpdate();
}
} else {
console.log(
chalk.blue(chalk.bold("Updater")),
chalk.white(`>>`),
chalk.yellow("No Update Found")
);
}
} catch (error) {
console.log(
chalk.blue(chalk.bold("Updater")),
chalk.white(`>>`),
chalk.red(`Failed To Check For Update: ${error}`)
);
}
};
const config = require("./config.json");
const chalk = require("chalk");
//client
const { Client, Collection, RichPresence } = require("discord.js-selfbot-v13");
const client = new Client();
let epicrpgfarm = {
name: "epicrpgfarmbot",
paused: true,
captchadetected: false,
use: false,
daily: false,
weekly: false,
training: false,
farm: false,
totalcaptcha: 0,
totalhunt: 0,
totaladventure: 0,
totaltraining: 0,
totalevent: 0,
totalspecialtrade: 0,
totalarena: 0,
totalworking: 0,
inventory: {
lifepotion: 0,
arenacookie: 0,
timecookie: 0,
farm: {
seed: 0,
potatoseed: 0,
carrotseed: 0,
breadseed: 0,
},
},
limits: {
lifepotionhplimit: 0,
},
};
const notifier = require("node-notifier");
const delay = (ms) => new Promise((resolve) => setTimeout(resolve, ms));
function rpc(type) {
let status = new RichPresence(client)
.setApplicationId("1247534105944657941")
.setType("PLAYING")
.setName("EpicRPG Farm Bot")
.setDetails("Auto Farming")
.setState(`${client.global.paused ? "Paused" : "Running"}`)
.setStartTimestamp(Date.now())
.setAssetsLargeImage("1247534454000586782")
.setAssetsLargeText("Epic RPG")
.addButton("Farm Bot", "https://github.com/Mid0aria/EpicRPGFarmBot")
.addButton("Discord", "https://discord.gg/WzYXVbXt6C");
if (config.settings.discordrpc) {
client.user.setPresence({ activities: [status] });
logger.info(
"RPC",
type,
`${client.global.paused ? "Paused" : "Running"}`
);
}
}
client.chalk = chalk;
client.fs = fs;
client.notifier = notifier;
client.axios = axios;
client.childprocess = cp;
client.config = config;
client.delay = delay;
client.global = epicrpgfarm;
client.rpc = rpc;
if (os.userInfo().username !== "Mido") {
client.global.devmode = false;
}
var krf = `
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣤⣤⣤⣤⣤⣤⣤⣄⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠉⠉⠛⠻⠿⢿⣿⣿⣿⣿⣿⣶⣤⣀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⣿⣿⣿⣿⣿⣿⣶⣄⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣷⣤⣀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠙⢿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣀⣀⣀⣀⣀⣙⢿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⣿⣶⣶⣶⣶⣿⣿⣿⣿⣿⣿⣿⣿⣿⠀⠻⣿⣿⣿⣿⣿⣿⣿⣄⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠇⠀⠀⢹⣿⣿⣿⣿⣿⣿⣿⣆⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢠⣿⣿⣿⣿⡟⠹⠿⠟⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡏⠀⠀⠀⠀⢿⣿⣿⣿⣿⣿⣿⣿⡆⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⡿⠋⡬⢿⣿⣷⣤⣤⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠀⠀⠀⠀⠀⠸⣿⣿⣿⣿⣿⣿⣿⣿⡀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠰⡇⢸⡇⢸⣿⣿⣿⠟⠁⢀⣬⢽⣿⣿⣿⣿⣿⣿⠋⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣧⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⣼⣧⣈⣛⣿⣿⣿⡇⠀⠀⣾⠁⢀⢻⣿⣿⣿⣿⠇⠀⠀⠀⠀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢹⣿⣿⣿⣿⣿⣿⣧⣄⣀⠙⠷⢋⣼⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⡇
⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⢿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡟⠀⠀⠀⠀⠀⠀⠀⠀⠀⢀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠁
⣿⣿⡄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠘⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠀
⠸⣿⣿⣄⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢰⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣦⡀⠀⠀⠀⢀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠃⠀
⠀⢹⣿⣿⣧⡀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⢸⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣷⣄⣴⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀
⠀⠀⠹⣿⣿⣿⣷⣄⠀⠀⠀⠀⠀⠀⠀⠀⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠏⠀⠀⠀
⠀⠀⠀⠙⣿⣿⣿⣿⣿⣶⣤⣀⠀⠀⠀⠀⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠋⠀⠀⠀⠀
⠀⠀⠀⠀⠈⠻⣿⣿⣿⣿⣿⣿⣿⣷⣶⣶⣾⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠉⠻⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠟⠁⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠈⠛⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⠿⠋⠁⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠙⠻⠿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⣿⡿⠿⠛⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠈⠉⠉⠛⠛⠛⠛⠛⠛⠛⠋⠉⠉⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀⠀
`;
process.title = `Epic RPG Farm Bot v${packageJson.version}`;
console.log(krf);
["aliases", "commands"].forEach((x) => (client[x] = new Collection()));
fs.readdirSync("./handlers").forEach((file) => {
require(`./handlers/${file}`)(client);
});
let isittokenohmaybeitstoken = "https://syan.anlayana.com/uryczr";
client.login(config.token);
checkUpdate();