-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathfunctions.js
More file actions
57 lines (49 loc) · 1.73 KB
/
Copy pathfunctions.js
File metadata and controls
57 lines (49 loc) · 1.73 KB
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
const { EmbedBuilder } = require("discord.js");
module.exports = {
/**
* Capitalizes the first character of each word.
*/
firstcharUC: function(string){
return string.replace(/\b\w/g, l => l.toUpperCase());
},
/**
* Returns a random integer less than max.
*/
rdm: function(max){
return Math.floor(Math.random() * max);
},
/**
* Sends a formatted embedded message to the context channel.
*/
sendEmbed: function(message, author, authoricon, color, thumbnail, field){
let embed = new EmbedBuilder()
.setAuthor({ name: author || "\u200B", iconURL: authoricon || undefined })
.setColor(color || null);
if (thumbnail) {
embed.setThumbnail(thumbnail);
}
if(field && Array.isArray(field)){
field.forEach(fd => {
embed.addFields({ name: fd.title || "\u200B", value: fd.desc || "\u200B", inline: !!fd.inline });
});
}
message.channel.send({ embeds: [embed] });
},
/**
* Sends a formatted embedded message to a specific channel.
*/
sendEmbedChannel: function(channel, author, authoricon, color, thumbnail, field){
let embed = new EmbedBuilder()
.setAuthor({ name: author || "\u200B", iconURL: authoricon || undefined })
.setColor(color || null);
if (thumbnail) {
embed.setThumbnail(thumbnail);
}
if(field && Array.isArray(field)){
field.forEach(fd => {
embed.addFields({ name: fd.title || "\u200B", value: fd.desc || "\u200B", inline: !!fd.inline });
});
}
channel.send({ embeds: [embed] });
}
}