-
-
Notifications
You must be signed in to change notification settings - Fork 85
/
config.js
141 lines (118 loc) · 5.44 KB
/
config.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
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
/*
zdiscord - by Tony/zfbx - https://github.com/zfbx/zdiscord - License: CC BY-NC-SA 4.0
Docs for this file available at https://zfbx.github.io/zdiscord/config or in docs/config.md
*/
/** ******************************
* GENERAL CONFIGURATION SETTINGS
********************************/
const LanguageLocaleCode = "en";
// PUBLIC VALUES
const FiveMServerName = "My FiveM Server";
const DiscordInviteLink = "https://discord.gg/fivem";
const FiveMServerIP = "127.0.0.1";
// This spams the console, only enable for testing if needed
const DebugLogs = false;
/** ********************
* DISCORD BOT SETTINGS
***********************/
const EnableDiscordBot = true;
// DISCORD BOT
const DiscordBotToken = "CHANGE";
const DiscordGuildId = "000000000000000000";
// STAFF CHAT
const EnableStaffChatForwarding = false;
const DiscordStaffChannelId = "000000000000000000";
const AdditionalStaffChatRoleIds = [
// "000000000000000",
];
// WHITELISTING / ALLOWLISTING
const EnableWhitelistChecking = true;
const DiscordWhitelistRoleIds = "000000000000000000, 000000000000000000";
// SLASH COMMANDS / DISCORD PERMISSIONS
const EnableDiscordSlashCommands = true;
const DiscordModRoleId = "000000000000000000";
const DiscordAdminRoleId = "000000000000000000";
const DiscordGodRoleId = "000000000000000000";
// DISCORD BOT STATUS
const EnableBotStatusMessages = true;
const BotStatusMessages = [
"{servername}",
"{playercount} online",
];
// ACE PERMISSIONS
const EnableAutoAcePermissions = false;
const AutoAcePermissions = {
// "example": "000000000000000000",
// "example2": [ "000000000000000000", "000000000000000000"],
};
// Other
const SaveScreenshotsToServer = false;
/** ************************
* WEBHOOK LOGGING SETTINGS
**************************/
const EnableLoggingWebhooks = false;
const LoggingWebhookName = "zLogs";
// put "&" in front of the id if you're to ping a role
const LoggingAlertPingId = "&000000000000000000";
// example: "bank": "https://discord.com/webhook/...",
const LoggingWebhooks = {
"example": "https://discord.com/api/webhooks/000000000/sEcRRet-ToK3n_5tUfF_tH8t_YUo-S40u1d-n07-sHar3",
};
/** !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!
* !! DO NOT EDIT BELOW THIS LINE UNLESS YOU KNOW WHAT YOU'RE DOING !!
* !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!*/
module.exports = {
EnableDiscordBot: getConBool("discord_enable_bot", EnableDiscordBot),
EnableStaffChatForwarding: getConBool("discord_enable_staff_chat", EnableStaffChatForwarding),
EnableLoggingWebhooks: getConBool("discord_enable_logging_webhooks", EnableLoggingWebhooks),
DebugLogs: getConBool("discord_debug", DebugLogs),
DiscordBotToken: GetConvar("discord_token", DiscordBotToken),
DiscordGuildId: GetConvar("discord_guild_id", DiscordGuildId),
LanguageLocaleCode: GetConvar("discord_lang", LanguageLocaleCode),
FiveMServerName: GetConvar("discord_server_name", FiveMServerName),
DiscordInviteLink: GetConvar("discord_invite", DiscordInviteLink),
FiveMServerIP: GetConvar("discord_server_ip", FiveMServerIP),
EnableWhitelistChecking: getConBool("discord_enable_whitelist", EnableWhitelistChecking),
DiscordWhitelistRoleIds: getConList("discord_whitelist_roles", DiscordWhitelistRoleIds),
EnableDiscordSlashCommands: getConBool("discord_enable_commands", EnableDiscordSlashCommands),
DiscordModRoleId: GetConvar("discord_mod_role", DiscordModRoleId),
DiscordAdminRoleId: GetConvar("discord_admin_role", DiscordAdminRoleId),
DiscordGodRoleId: GetConvar("discord_god_role", DiscordGodRoleId),
EnableBotStatusMessages: getConBool("discord_enable_status", EnableBotStatusMessages),
BotStatusMessages: BotStatusMessages,
EnableAutoAcePermissions: getConBool("discord_enable_ace_perms", EnableAutoAcePermissions),
AutoAcePermissions: AutoAcePermissions,
SaveScreenshotsToServer: getConBool("discord_save_screenshots", SaveScreenshotsToServer),
DiscordStaffChannelId: GetConvar("discord_staff_channel_id", DiscordStaffChannelId),
LoggingWebhooks: LoggingWebhooks,
LoggingAlertPingId: GetConvar("discord_logging_ping_id", LoggingAlertPingId),
LoggingWebhookName: GetConvar("discord_logging_name", LoggingWebhookName),
StaffChatRoleIds: [
GetConvar("discord_mod_role", DiscordModRoleId),
GetConvar("discord_admin_role", DiscordAdminRoleId),
GetConvar("discord_god_role", DiscordGodRoleId),
...AdditionalStaffChatRoleIds,
],
};
/** Returns convar or default value fixed to a true/false boolean
* @param {boolean|string|number} con - Convar name
* @param {boolean|string|number} def - Default fallback value
* @returns {boolean} - parsed bool */
function getConBool(con, def) {
if (typeof def == "boolean") def = def.toString();
const ret = GetConvar(con, def);
if (typeof ret == "boolean") return ret;
if (typeof ret == "string") return ["true", "on", "yes", "y", "1"].includes(ret.toLocaleLowerCase().trim());
if (typeof ret == "number") return ret > 0;
return false;
}
/** returns array of items or default array provided
* @param {string} con - string of comma separated values
* @param {string|Array} def - string of comma separated values
* @returns {object} - array of discord ids */
function getConList(con, def) {
const ret = GetConvar(con, def);
if (typeof ret == "string") return ret.replace(/[^0-9,]/g, "").replace(/(,$)/g, "").split(",");
if (Array.isArray(ret)) return ret;
if (!ret) return [];
}