This repository has been archived by the owner on Mar 3, 2022. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
/
functions.js
53 lines (44 loc) · 1.71 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
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)
});
}
if (!target)
target = message.member;
return target;
},
formatDate: function(date) {
return new Intl.DateTimeFormat('en-US').format(date)
},
promptMessage: async function (message, author, time, validReactions) {
time *= 1000;
for (const reaction of validReactions) await message.react(reaction);
const filter = (reaction, user) => validReactions.includes(reaction.emoji.name) && user.id === author.id;
return message
.awaitReactions(filter, { max: 1, time: time})
.then(collected => collected.first() && collected.first().emoji.name);
},
hasPerms: function(author, perms, message) {
var fs = require("fs");
var path = require('path');
let jsonPath = path.join(__dirname,'Users', author.id);
if ((fs.existsSync(jsonPath))) {
let json = JSON.parse(fs.readFileSync(jsonPath))
if (json.rank == perms){
return true
message.channel.send("True")
}
else return false
message.channel.send("False: " + json.rank + "and" + perms + "are not the same")
}
else return false
message.channel.send("User not found")
}
};