-
Notifications
You must be signed in to change notification settings - Fork 0
/
embed.js
72 lines (70 loc) · 2.42 KB
/
embed.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
const { RichEmbed } = require('discord.js');
const yml = require('./yml.js');
let Theme_Color = parseInt("#fffff", 16);
let Error_Color = parseInt("#f52c2c", 16);
let Config = {};
let Language = {};
(async () => {
const config = await yml('./config.yml');
Config = config;
Theme_Color = parseInt(config.Theme_Color.replace(/#/g, ''), 16);
Error_Color = parseInt(config.Error_Color.replace(/#/g, ''), 16);
Language = await yml("./lang.yml");
})()
module.exports = function (embedOptions) {
if (embedOptions.preset) {
switch (embedOptions.preset) {
case 'nopermission':
return {
embed: {
color: Error_Color,
title: "**No Permission**",
description: Language.Insufficient_Permission_Message,
timestamp: new Date()
}
}
case 'invalidargs':
return {
embed: {
color: Error_Color,
title: "**Invalid Arguments**",
description: `Usage: \`\`${Config.Bot_Prefix}${embedOptions.usage}\`\``,
timestamp: new Date()
}
}
case 'errorinfo':
return {
embed: {
color: Error_Color,
title: 'Error',
description: `${embedOptions.usage}`
}
}
default:
return {
embed: {
color: Theme_Color,
title: "Error",
description: "An error has occured."
}
}
}
} else {
const embed = embedOptions;
if (embed.color) embed.color = parseInt(embed.color.replace(/#/g, ''), 16);
else embed.color = Theme_Color;
if (embed.footer) {
const footer = embed.footer;
if (typeof footer == "string")
embed.footer = { text: footer };
}
if (embed.author) {
const author = embed.author;
if (typeof author == "string")
embed.author = { name: author };
}
if (embed.thumbnail)
embed.thumbnail = { url: embed.thumbnail };
return { embed: embed };
}
}