Created
August 14, 2025 22:28
-
-
Save BigBang1112/6c5f48f2829d215c91dd5580322b4e47 to your computer and use it in GitHub Desktop.
Most native way to resend TM2020/ManiaPlanet server chat messages to a Discord channel.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| #RequireContext CServerPlugin | |
| #Include "TextLib" as TextLib | |
| #Setting S_DiscordWebhook "" | |
| #Struct SDiscordWebhookExecute { | |
| Text content; | |
| Text username; | |
| Text avatar_url; | |
| } | |
| main() { | |
| while (True) { | |
| foreach (Event in PendingEvents) { | |
| if (Event.Type == CServerPluginEvent::EType::ChatMessage) { | |
| declare SDiscordWebhookExecute Execute; | |
| Execute.content = TextLib::StripFormatting(Event.ChatText); | |
| Execute.username = TextLib::StripFormatting(Event.Client.User.Name); | |
| if (TextLib::StartsWith("http://", Event.Client.User.AvatarUrl) || TextLib::StartsWith("https://", Event.Client.User.AvatarUrl)) | |
| Execute.avatar_url = Event.Client.User.AvatarUrl; | |
| declare Request = Http.CreatePost(S_DiscordWebhook, Execute.tojson(), "Content-Type: application/json"); | |
| } | |
| } | |
| foreach (Event in Http.PendingEvents) { | |
| Http.Destroy(Event.Request); | |
| } | |
| yield; | |
| } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment