-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathutils.js
44 lines (34 loc) · 987 Bytes
/
utils.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
class Utils {
constructor(bot, client) {
this.bot = bot;
this.client = client;
}
getUser(username) {
return this.client.users.find(user => user.username === username && !user.bot);
}
removeBotName(content) {
return content.replace(this.bot.halanRegexp, "");
}
getTargetChannelAndClean(message) {
}
getTargetUserAndClean(message) {
let content = message.content;
}
resolveToMentions(message) {
let possibleMentions = message.content.match(/@[A-Za-z]*\b/);
if (!possibleMentions) return;
let mentionedUsers = possibleMentions.map( pMention =>
this.getUser(pMention.replace("@", "")));
mentionedUsers.forEach(user => {
if(user){
console.log(user);
message.mentions.users.set(user.id, user)
}
});
return;
}
getRandom(array) {
return array[Math.floor(Math.random()*array.length)];
}
}
module.exports = Utils;