Files
GTA4RP/scripts/server/discord.js
Vortrex 9d8d5d1418 Bunch of changes (see description)
* New script files to organize GUI
* Added clientside pickup detection to reduce server load for enter/exit
* Added notips command for players to toggle random tips
* Select account last IP as part of wildcard (was separate due to old INT)
* Save account registration with datetime instead of unix timestamp
* Don't force mouse camera on moving anims in SA+
* Add IP ban to server runtime memory in subnet ban command
* Add non-roleplay character name account moderation flag
* Fix bizowner and bizclan commands
* Fix bug that allowed buying items without having the needed cash
* Fix set biz blip command
* Add dealership help label type command
* Added command to show all clan flag types
* Added discord config and load from database
* Fix angle for directional teleport and anim move directions
* Use new colour structure in preparation for locale translations
* Add on-foot only item usetype array to prevent using when in veh
* Fix wrong const value for exit pickup type
* Start using datetime in MySQL tables instead of unix timestamps
* Start adding webhooks for discord (unfinished)
* Added new discord URL to discord help category
* Added house reset pickups/blips utils
* Prevent using items when in skin selector
* Fix get player command
* Fix give player money command
* Add coffee shop and vehicle repair shop default biz item templates
* Remove old game fixes util (resource now in server config)
* Fix bug where characters in clans wouldn't be shown in char select
* Slimmed down the amount of timers
* Made some potentially large numbers more readable (commas)
* Remove colours in message for console output
2021-09-28 11:41:33 -05:00

140 lines
4.0 KiB
JavaScript

// ===========================================================================
// Vortrex's Roleplay Resource
// https://github.com/VortrexFTW/gtac_roleplay
// ===========================================================================
// FILE: discord.js
// DESC: Provides discord bridging and connection functions and usage
// TYPE: Server (JavaScript)
// ===========================================================================
function initDiscordScript() {
logToConsole(LOG_INFO, "[VRR.Discord]: Initializing discord script ...");
logToConsole(LOG_INFO, "[VRR.Discord]: Discord script initialized successfully!");
}
// ===========================================================================
/*
addEventHandler("OnDiscordCommand", function(command, params, discordUser) {
let commandData = getCommand(command);
if(!commandData) {
messagePlayerError(discordUser, "That command does not exist!");
return false;
}
if(isCommandAllowedOnDiscord(command)) {
messagePlayerError(discordUser, "That command can not be used on Discord!");
return false;
}
if(doesClientHavePermission(discordUser, getCommandRequiredPermissions(command))) {
messagePlayerError(discordUser, "You do not have permission to use that command!");
return false;
}
commandData.handlerFunction(command, params, discordUser);
});
*/
// ===========================================================================
function messageDiscordUser(discordUser, messageText) {
let socketData = JSON.stringify({
type: "chat.message.text",
payload: {
author: discordUser.name,
text: messageText,
}
});
sendDiscordSocketData(socketData);
}
// ===========================================================================
function sendDiscordSocketData(socketData) {
if(!getDiscordSocket()) {
return false;
}
getDiscordSocket().send(module.hash.encodeBase64(socketData) + "\r\n");
}
// ===========================================================================
function isClientFromDiscord(client) {
if(client == null) {
return false;
}
if(client instanceof Client) {
return false;
} else {
return true;
}
}
// ===========================================================================
function getDiscordSocket() {
return false;
}
// ===========================================================================
function getDiscordUserData(discordUserId) {
return loadAccountFromDiscordUserId(discordUserId);
}
// ===========================================================================
function messageDiscordChatChannel(message) {
if(!getServerConfig().discordConfig.sendChat) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Chat",
"content": message,
};
triggerWebHook(getServerConfig().discordConfig.chatChannelWebHookURL, JSON.stringify(payloadData));
}
// ===========================================================================
function messageDiscordAdminChannel(message) {
if(!getServerConfig().discordConfig.sendAdminEvents) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Admin Event",
"content": message,
};
triggerWebHook(getServerConfig().discordConfig.adminChannelWebHookURL, JSON.stringify(payloadData));
}
// ===========================================================================
function messageDiscordEventChannel(message) {
if(!getServerConfig().discordConfig.sendEvents) {
return false;
}
message = removeColoursInMessage(message);
console.warn(message);
let payloadData = {
"username": "Event",
"content": message,
};
triggerWebHook(getServerConfig().discordConfig.eventChannelWebHookURL, JSON.stringify(payloadData));
}
// ===========================================================================