-
Notifications
You must be signed in to change notification settings - Fork 4
/
Copy pathutils.js
32 lines (26 loc) · 852 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
export const load = (command_files, client) => {
command_files.map(async command_file => {
let {default: command} = await import(`./bot/commands/${command_file}`);
client.commands.set(command.name, command);
});
};
export const getUserFromMention = (message, mention) => {
if (!mention) return;
if (mention.startsWith('<@') && mention.endsWith('>')) {
mention = mention.slice(2, -1);
if (mention.startsWith('!')) {
mention = mention.slice(1);
}
return message.guild.members.cache.get(mention);
}
}
export const getRoleFromMention= (message, mention) => {
if (!mention) return;
if (mention.startsWith('<@') && mention.endsWith('>')) {
mention = mention.slice(2, -1);
if (mention.startsWith('&')) {
mention = mention.slice(1);
}
return message.guild.roles.cache.get(mention);
}
}