This repository has been archived by the owner on Aug 13, 2023. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathfunctions.js
77 lines (59 loc) · 2.74 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
68
69
70
71
72
73
74
75
76
77
/***************************************************************************/
/* */
/* Made by Mr Swift */
/* Best Source FOR Discord Bot */
/* Server Support :https://discord.gg/6Zgu6TN */
/* My instagram : Mr_.swift */
/* Copyright: 2020 */
/* */
/***************************************************************************/
module.exports = {
getMember: function(message, toFind = '') {
toFind = toFind.toLowerCase();
let target = message.guild.members.get(toFind);
if (!target && message.mentions.members)
target = message.mentions.members.first();
if (!target && toFind) {
target = message.guild.members.find(member => {
return member.displayName.toLowerCase().includes(toFind) ||
member.user.tag.toLowerCase().includes(toFind)
});
}
/* Made by Mr Swift */
if (!target)
target = message.member;
return target;
},
formatDate: function(date) {
return new Intl.DateTimeFormat('en-US').format(date)
},
shuffle: function (array) {
var i = array.length,
j = 0,
temp;
while (i--) {
j = Math.floor(Math.random() * (i+1));
// swap randomly chosen element with current element
temp = array[i];
array[i] = array[j];
array[j] = temp;
}
return array;
},
promptMessage: async function (message, author, time, validReactions) {
// We put in the time as seconds, with this it's being transfered to MS
time *= 1000;
// For every emoji in the function parameters, react in the good order.
for (const reaction of validReactions) await message.react(reaction);
// Only allow reactions from the author,
// and the emoji must be in the array we provided.
const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
// And ofcourse, await the reactions
return message
.awaitReactions(filter, { max: 1, time: time})
.then(collected => collected.first() && collected.first().emoji.name);
},
sleep: function (loger,time) {
setTimeout(() => { console.log(`${loger}!`); }, time);
}
};