-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathbrand.js
More file actions
77 lines (71 loc) · 3.15 KB
/
Copy pathbrand.js
File metadata and controls
77 lines (71 loc) · 3.15 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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
/**
* =============================================================================
* THE BOT'S BRAND — the first file a fork edits.
* =============================================================================
*
* This is the only place in the code that names and colors the bot. Changing
* the values below and replacing two images puts your brand on the whole bot,
* with no stray strings to hunt down in a command or an embed.
*
* Everything here can be overridden by an environment variable, without
* editing a file: that's what lets the SAME image run for different clients,
* each with its own `.env`. The file is the default; the environment wins.
*
* -----------------------------------------------------------------------------
* HOW TO SWAP THE BRAND
* -----------------------------------------------------------------------------
*
* 1. Edit `NOME` and `CORES` below — or set `BRAND_NAME` and `BRAND_COLOR`
* in `.env`, which is the recommended path for a new client.
*
* 2. Replace the two files in `assets/`, keeping the names:
*
* assets/logo.webp the mark, used as the embed thumbnail
* assets/banner.webp the wide README artwork
*
* Prefer different names? Change the paths in `ARQUIVOS` too.
*
* 3. `npm run check` — validates that the colors are valid hexadecimal and
* that the referenced files exist.
*
* After that, `grep -ri nerdresolve src/` should only find this file.
*/
/** Reads a color from the environment, accepting `#7C3AED` or `7C3AED`. */
function corDoAmbiente(chave, padrao) {
const bruto = process.env[chave]?.trim();
if (!bruto) return padrao;
const hex = bruto.replace(/^#/, '');
if (!/^[0-9a-fA-F]{6}$/.test(hex)) {
console.warn(`[WARN] ${chave}="${bruto}" is not a 6-digit hex color. Using the default.`);
return padrao;
}
return Number.parseInt(hex, 16);
}
/** The bot's name. Shows up in every embed footer and in /help. */
export const NOME = process.env.BRAND_NAME?.trim() || 'NerdBot';
/** The project's address. Used in /help and /status. */
export const SITE = process.env.BRAND_URL?.trim() || 'https://nerdresolve.com';
/**
* The four embed colors, in hexadecimal.
*
* `BRAND` is the brand color and carries most of the replies. The other three
* are semantic: success, warning and error. They keep their meaning under any
* brand, which is why only `BRAND` usually changes from client to client.
*/
export const CORES = Object.freeze({
/** NerdResolve violet (--violet-500). The default identity. */
BRAND: corDoAmbiente('BRAND_COLOR', 0x7C3AED),
/** Confirmation green. */
SUCCESS: corDoAmbiente('BRAND_COLOR_SUCCESS', 0x22C55E),
/** Attention amber. */
WARNING: corDoAmbiente('BRAND_COLOR_WARNING', 0xF59E0B),
/** Failure red. */
ERROR: corDoAmbiente('BRAND_COLOR_ERROR', 0xEF4444),
});
/** Where the brand images live, relative to the project root. */
export const ARQUIVOS = Object.freeze({
/** The mark, used as the embed thumbnail. */
logo: process.env.BRAND_LOGO?.trim() || 'assets/logo.webp',
/** The wide README artwork. */
banner: process.env.BRAND_BANNER?.trim() || 'assets/banner.webp',
});