-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbot.js
More file actions
94 lines (87 loc) · 3.14 KB
/
bot.js
File metadata and controls
94 lines (87 loc) · 3.14 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
const Discord = require("discord.js");
const logger = require("winston");
const auth = require("./auth.json");
const spawn = require("child_process").spawn;
logger.remove(logger.transports.Console);
logger.add(new logger.transports.Console(), {
colorize: true,
});
logger.level = "debug";
const client = new Discord.Client();
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`);
});
let authors = [];
client.on("message", (message) => {
if (message.content.substring(0, 1) == "!") {
var args = message.content.substring(1).split(" ");
var cmd = args[0];
args = args.splice(1);
switch (cmd) {
case "bc": {
const embed3 = new Discord.MessageEmbed()
.setTitle("Do you have bits?")
.setColor("#80ff00")
.setAuthor(message.author.username)
.setDescription("React with the ✅ or the ❌");
message.reply(embed3).then((rMes) => {
rMes.react("✅").then(() => rMes.react("❌"));
const filter = (reaction, user) => {
return (
["✅", "❌"].includes(reaction.emoji.name) &&
user.id === message.author.id
);
};
rMes
.awaitReactions(filter, { max: 1, time: 60000, errors: ["time"] })
.then((collected) => {
const embed4 = new Discord.MessageEmbed()
.setTitle("How many bits do you have?")
.setColor("#80ff00")
.setDescription("Please answer with an integer...");
const reaction = collected.first();
if (reaction.emoji.name === "✅") {
message.reply(embed4);
authors.push(message.author.id);
} else {
}
});
});
break;
}
case "bchelp": {
const embed2 = new Discord.MessageEmbed()
.setTitle("You needed help?")
.setColor("#80ff00")
.setAuthor(message.author.username)
.setDescription(
"Commands = !bc followed by integer for number of Bits. \n Will calculate best items to buy, but buy quickly as prices can fluctuate. \n V2 with further commands coming soon!"
);
message.channel.send(embed2).then((msg) => msg.react("👌"));
}
}
}
if (authors.indexOf(message.author.id) != -1) {
if (!isNaN(message.content)) {
const embed5 = new Discord.MessageEmbed()
.setTitle("Ok, Getting data...")
.setColor("#80ff00");
message.reply(embed5);
let bits = message.content;
const pythonProcess = spawn("python3", ["./apiTesting.py", bits]);
pythonProcess.stdout.on("data", (data) => {
let out = data.toString();
const embed = new Discord.MessageEmbed()
.setTitle("Here is the data, bois")
.setColor("#80ff00")
.setAuthor(message.author.username)
.setDescription(out);
message.channel.send(embed).then((msg) => msg.react("🤑"));
});
} else {
message.reply("Learn what a number is you dumb bitch!");
}
authors.splice(authors.indexOf(message.author.id), 1);
}
});
client.login(auth.token);