(path, fallback = "#99AAB5")
| 513 | export const BotConfig = botConfig; |
| 514 | |
| 515 | export function getColor(path, fallback = "#99AAB5") { |
| 516 | |
| 517 | if (typeof path === "number") return path; |
| 518 | if (typeof path === "string" && path.startsWith("#")) { |
| 519 | |
| 520 | return parseInt(path.replace("#", ""), 16); |
| 521 | } |
| 522 | const result = path |
| 523 | .split(".") |
| 524 | .reduce( |
| 525 | (obj, key) => (obj && obj[key] !== undefined ? obj[key] : fallback), |
| 526 | botConfig.embeds.colors, |
| 527 | ); |
| 528 | |
| 529 | if (typeof result === "string" && result.startsWith("#")) { |
| 530 | return parseInt(result.replace("#", ""), 16); |
| 531 | } |
| 532 | return result; |
| 533 | } |
| 534 | |
| 535 | export function getRandomColor() { |
| 536 | const colors = Object.values(botConfig.embeds.colors).flatMap((color) => |
no outgoing calls
no test coverage detected