-
Notifications
You must be signed in to change notification settings - Fork 1
/
functions.js
67 lines (61 loc) · 1.93 KB
/
functions.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
//HELPER FUNCTIONS
//Function to fill an array with JSON data (in this case, word (the words that rhyme with the random generated word))
//Returns true if new array, false if old
function fillJsonArray(json, arr) {
if (arr.length === 0) {
for (let i = 0; i < json.length; i++) {
let temp = json[i].word;
if (temp.includes(" ") == false) {
arr.push(json[i].word);
}
}
return true;
}
return false;
}
//Basic helper function for first message bot sends on ^rhyme command
async function initialMessage(channelID, word, counter, check, maxCounter, bot) {
if (check) {
bot.sendMessage({
to: channelID,
message:
`:wave: Name 10 words that rhyme with **${word}**! :point_right: Possible words: **` +
counter +
"**!",
});
} else {
bot.sendMessage({
to: channelID,
message:
`:face_with_monocle: The current word to rhyme with is: **${word}**! *` +
maxCounter +
` more!*`,
});
}
}
//Basic helper function for follow up message bot sends after a correct word is listened to
function followUpMessage(channelID, message, word, maxCounter, counter, bot) {
bot.sendMessage({
to: channelID,
message:
"☑️ **" +
message +
`** rhymes with the word **${word}!** *` +
maxCounter +
" more!* :point_right: Possible words: **" +
counter +
"**!",
});
}
//Basic helper function for final bot sends when word has been rhymed 10 times
function finalMessage(channelID, message, word, bot) {
bot.sendMessage({
to: channelID,
message:
"☑️ **" +
message +
`** rhymes with the word **${word}!** ` +
`:astonished: You rhymed **${word}** with 10 words! :smile:`,
});
}
module.exports = { fillJsonArray, initialMessage, followUpMessage, finalMessage };