Skip to content

Commit

Permalink
Improve !report Command
Browse files Browse the repository at this point in the history
- Allows players to add descriptions of their reports so the information is relayed to Discord admins
  • Loading branch information
data-bomb committed Jan 17, 2024
1 parent 8bbfceb commit 82462a1
Showing 1 changed file with 16 additions and 4 deletions.
20 changes: 16 additions & 4 deletions Si_Webhooks/Si_Webhooks.cs
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ You should have received a copy of the GNU General Public License
using Newtonsoft.Json;
using static System.Net.Mime.MediaTypeNames;

[assembly: MelonInfo(typeof(Webhooks), "Webhooks", "1.2.1", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonInfo(typeof(Webhooks), "Webhooks", "1.2.2", "databomb", "https://github.com/data-bomb/Silica")]
[assembly: MelonGame("Bohemia Interactive", "Silica")]
[assembly: MelonOptionalDependencies("Admin Mod")]

Expand Down Expand Up @@ -133,11 +133,23 @@ public static void Postfix(Silica.UI.Chat __instance, Player __0, string __1, bo
}

// is this a user report?
bool isUserReport = String.Equals(rawMessage, "!report", StringComparison.OrdinalIgnoreCase);
int spaceCharacter = rawMessage.IndexOf(" ");
string commandText = (spaceCharacter == -1) ? rawMessage : rawMessage.Substring(0, spaceCharacter);

bool isUserReport = String.Equals(commandText, "!report", StringComparison.OrdinalIgnoreCase);
if (isUserReport)
{
rawMessage = __0.PlayerName + "(" + __0.PlayerID.ToString() + ") is requesting an admin in the game. <@&" + _RoleToMentionForReports.Value + ">";
SendMessageToWebhook(rawMessage, _Server_Shortname.Value, _Server_Avatar_URL.Value);
string reportMessage;
if (spaceCharacter == -1)
{
reportMessage = __0.PlayerName + " (" + __0.PlayerID.ToString() + ") is requesting an admin in the game. <@&" + _RoleToMentionForReports.Value + ">";
}
else
{
reportMessage = __0.PlayerName + " (" + __0.PlayerID.ToString() + ") is requesting an admin in the game. Report:" + rawMessage.Substring(spaceCharacter) + " <@&" + _RoleToMentionForReports.Value + ">";
}

SendMessageToWebhook(reportMessage, _Server_Shortname.Value, _Server_Avatar_URL.Value);
return;
}

Expand Down

0 comments on commit 82462a1

Please sign in to comment.