-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathindex.js
112 lines (98 loc) · 3.45 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
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
/**
* A simple Discord bot that responds according to user's input
*/
const Discord = require('discord.js');
const config = require("./config.json");
const myIntents = new Discord.Intents();
myIntents.add(Discord.Intents.FLAGS.GUILDS);
myIntents.add(Discord.Intents.FLAGS.GUILD_MESSAGES);
const client = new Discord.Client({
intents: myIntents,
});
client.on('ready', function (myClient) {
//generate link
let inviteLink = myClient.generateInvite({
scopes: ['bot']
});
//print the link for the user to invite the bot to their server
console.log("Invite the bot to your server\n\t{{{ " + inviteLink + " }}}");
});
client.on('messageCreate', function (userInput) {
//if the input is from the bot itself, do nothing
if (userInput.author.bot) {
return;
}
//international greeting
const greetings = ["hello", "hi", "welcome", "hey", "wassup"];
const greetings2 = ["Bonjour", "Hola", "Xin chao", "Konnichiwa", "Aloha"];
//respond international greeting
if (greetings.some(word => userInput.content.includes(word))) {
const greeting = greetings2[Math.floor(Math.random() *greetings2.length)]
userInput.reply(greeting);
return;
}
//The Twelve Days of Christmas
switch(userInput.content)
{
case '1':
userInput.reply("partridge in a pear tree");
return;
case '2':
userInput.reply("turtle doves");
return;
case '3':
userInput.reply("French hens");
return;
case '4':
userInput.reply("calling birds");
return;
case '5':
userInput.reply("golden rings");
return;
case '6':
userInput.reply("geese a-laying");
return;
case '7':
userInput.reply("swans a-swimming");
return;
case '8':
userInput.reply("maids a-milking");
return;
case '9':
userInput.reply("ladies dancing");
return;
case '10':
userInput.reply("lords a-leaping");
return;
case '11':
userInput.reply("pipers piping");
return;
case '12':
userInput.reply("drummers drumming");
return;
default:
break;
}
//respond to the bot name
if (userInput.content.includes("891519385179680799")) {
userInput.reply("Heeeeey, thank you for calling my name, <@" + userInput.author + "> !");
return;
} else if (userInput.content.includes("Second") || userInput.content.includes("second")){
userInput.reply("Heeeeey, thank you for calling my name, <@" + userInput.author + "> !");
}
//emoji detector
// if((userInput.content.includes("<:") && userInput.content.includes("<a:")) && userInput.content.includes(">")){
// userInput.reply("Nice emoji, <@" + userInput.author + "> "+ userInput.content);
// return;
// }
//random responses
if ('a' <= userInput.content[0].toLowerCase() && userInput.content[0].toLowerCase() < 'm') {
userInput.reply(userInput.content + " is delicious.");
} else if ('m' <= userInput.content[0].toLowerCase() && userInput.content[0].toLowerCase() <= 'z') {
userInput.reply("I also love " + userInput.content);
} else {
userInput.reply("Let me unencrypt " + userInput.content + "... ");
}
return;
});
client.login(config.token);