Skip to content

Instantly share code, notes, and snippets.

@BigBang1112
Created August 14, 2025 22:28
Show Gist options
  • Select an option

  • Save BigBang1112/6c5f48f2829d215c91dd5580322b4e47 to your computer and use it in GitHub Desktop.

Select an option

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.
#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