-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
51 lines (43 loc) · 1.19 KB
/
index.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
const Discord = require('discord.js');
const client = new Discord.Client();
client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
const convertEmoji = (who) => {
if(who === "가위"){
return "🤘";
}
else if(who === "바위"){
return "👊";
}
else if(who === "보"){
return "✋";
}
}
client.on('message', msg => {
if(msg.content === "야"){
msg.reply("호!");
}
if(msg.content === "가위" || msg.content === "바위" || msg.content === "보") {
const human = msg.content;
const list = ["가위", "바위", "보"];
const random = Math.floor(Math.random() * 3);
const bot = list[random];
let winner = "";
if(human === bot) {
winner = "비김";
}
else {
human === "가위" ? (winner = bot === "바위" ? "봇" : "인간") : "";
human === "바위" ? (winner = bot === "보" ? "봇" : "인간") : "";
human === "보" ? (winner = bot === "가위" ? "봇" : "인간") : "";
}
const result =
`
사람 : ${convertEmoji(human)} vs 봇 : ${convertEmoji(bot)}
${winner === "비김" ? "우리는 비겼다 인간." : winner + "의 승리다"}
`
msg.reply(result);
}
});
client.login('');