void StacDetectionDiscordNotify(int userid, char[] type, int detections)
{
static char detectionTemplate[1024] = \
"{ \"embeds\": [ { \"title\": \"%t\", \"color\": 16738740, \"fields\": [ { \"name\": \"%t\", \"value\": \"%N\" } , { \"name\": \"SteamID\", \"value\": \"%s\" }, { \"name\": \"%t\", \"value\": \"%s\" }, { \"name\": \"%t\", \"value\": \"%i\" }, { \"name\": \"%t\", \"value\": \"%s\" }, { \"name\": \"%t\", \"value\": \"%s\" } , { \"name\": \"%t\", \"value\": \"%s\" } , { \"name\": \"%t\", \"value\": \"%i\" } ] } ] }";
if (!DISCORD)
{
return;
}
char msg[1024];
int Cl = GetClientOfUserId(userid);
char ClName[64];
GetClientName(Cl, ClName, sizeof(ClName));
Discord_EscapeString(ClName, sizeof(ClName));
GetDemoName();
// we technically store the url in this so it has to be bigger
char steamid[96];
// ok we store these on client connect & auth, this shouldn't be null
if (!IsActuallyNullString(SteamAuthFor[Cl]))
{
// make this a clickable link in discord
Format(steamid, sizeof(steamid), "[%s](https://steamid.io/lookup/%s)", SteamAuthFor[Cl], SteamAuthFor[Cl]);
}
// if it is, that means the plugin reloaded or steam is being fussy.
else
{
steamid = "N/A";
}
SetGlobalTransTarget( LANG_SERVER ); // new
Format
(
msg,
sizeof(msg),
detectionTemplate,
"discord_detection_title" // new
"discord_player_field", // new
Cl,
steamid,
"discord_detection_type_field", // new
type,
"discord_detection_count_field", // new
detections,
"discord_hostname_field", // new
hostname,
"discord_hostip_field", // new
hostipandport,
"discord_demo_field", // new
demoname,
"discord_unix_timestamp_field", // new
GetTime()
);
SendMessageToDiscord(msg);
}
StacDetectionDiscordNotify
andStacGeneralPlayerDiscordNotify
should be translatable (especiallytitle
andname
keys).For example:
Snippet: