-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathindex.js
More file actions
73 lines (60 loc) · 2.05 KB
/
Copy pathindex.js
File metadata and controls
73 lines (60 loc) · 2.05 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
//Invite Bot : https://discordapp.com/oauth2/authorize?client_id=692734199857152022&scope=bot&permissions=8
const entries = require("./entry");
const wordDAO = require("./wordDAO");
const gameDAO = require("./gameDAO");
const map = require("./map");
const game = require("./game");
secretToken = "NjkyNzM0MTk5ODU3MTUyMDIy.XnzBdg.OPbSQVemDjUGLysiwHaJmD9Qtdw";
const prefix = "/cd";
const Discord = require("discord.js")
const client = new Discord.Client()
client.on("ready", () => {
console.log(`Logged in as ${client.user.tag}!`)
})
client.on("message", message => {
if (!message.guild) {
return 0;
};
content = message.content.split(' ');
if (content[0] == prefix) {
param = {
bot : client,
tab : content,
msg : message,
wDAO : wordDAO,
gDAO : gameDAO,
g : game,
map : map
}
if (content[1] !== undefined) {
if (entries[content[1].toLowerCase()] != undefined) {
condition = entries[content[1].toLowerCase()].condition;
action = entries[content[1].toLowerCase()].action;
execute(condition, action, param).catch(err => message.channel.send(err));
} else
message.channel.send("Mmh je ne connais pas ce nom de code...");
} else message.channel.send("Il faut me préciser une commande.");
}
})
client.login(secretToken)
execute = function (condition, action, param) {
return new Promise(function(resolve, reject) {
try {
can = true;
if (condition != undefined) {
condition.forEach(cond => {
if (!cond.fun(param)) {
reject(cond.msg)
can = false
}
});
}
if (can)
action(param);
resolve();
} catch (error) {
reject("Mayday mayday ! Nous avons une erreur : " + error);
console.log(error)
}
})
}