This repository has been archived by the owner on Nov 7, 2018. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 4
/
wolfaxtra.js
79 lines (65 loc) · 2.16 KB
/
wolfaxtra.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
78
79
const Discord = require('discord.js');
(function() {
module.exports.nlength = function(number) {
if (typeof number === "undefined") return 0;
return Math.ceil(Math.log(number + 1) / Math.LN10);
}
module.exports.embed = function(title = false, description = false, thumbnail = 'https://himbeer.me/images/logo-monochrome.png', color = false) {
var embed = new Discord.RichEmbed();
if (title) embed.setTitle(title);
if (description) embed.setDescription(description);
if (thumbnail) embed.setThumbnail(thumbnail);
if (color) embed.setColor(color)
else embed.setColor(Math.floor(Math.random() * 16777215));
return embed;
}
module.exports.UnrealEmbed = class UnrealEmbed {
constructor(title = false, description = false, rows = false, dots = '•', maxlength = 2048) { // 2048 to fit into a normal embed's description
this.title = title;
this.desc = description;
this.rows = rows;
this.dots = dots;
this.maxlength = maxlength;
}
toString() {
return (this.title ? `**${this.title}**` : '') + (this.desc ? `\n${this.desc}` : '') + (this.rows ? this.rows.map(row => `\n${this.dots} __${row[0]}:__ ${row[1]}`).join('') : '');
}
checkLength() {
if (this.toString().length > this.maxlength) {
throw new RangeError('This SmallEmbed must not be longer than ${this.maxlength} chars!');
} else {
return this;
}
}
setTitle(title) {
this.title = title;
return this.checkLength();
}
setDesc(description) {
this.desc = description;
return this.checkLength();
}
addField(name, value) {
if (!this.rows) this.rows = [];
this.rows.push([name, value]);
return this.checkLength();
}
setDots(dots) {
this.dots = dots;
return this.checkLength();
}
}
module.exports.SubFields = class SubFields {
constructor(data = [], dots = '•') {
this.data = data;
this.dots = dots;
}
toString() {
return this.data.map(d => `\n${this.dots} __${d[0]}:__ ${d[1]}`).join('');
}
addField(name, value) {
this.data.push([name, value]);
return this;
}
}
}());