-
Create a Discord Webhook in your server channel by going to Edit channel → Integrations → Webhooks → Create Webhook. Configure the name, avatar and channel, then copy the webhook URL.
-
Create a webhook instance and start sending messages:
// Create webhook instance webhook = new DiscordWebhook("YOUR_WEBHOOK_URL"); // Send a simple message webhook.SetContent("Hello from GameMaker!") .Execute();
-
Create rich embeds for better presentation:
// Create an embed embed = new DiscordEmbed(); embed.SetTitle("Game Stats") .SetDescription("Player achievements") .SetColor(0x00ff00) .AddField("Score", string(score), true) .AddField("Level", string(level), true); // Send the embed webhook.AddEmbed(embed) .Execute();
-
Call the function
webhook.Async(trace)in an Async HTTP event to get the message ID, in order to use features likeProcessed(),Edit()orDelete():// Async HTTP Event webhook.Async(true); // Anywhere if (webhook.Processed()) { show_debug_message("Message sent successfully!"); }
Send screenshots, logs or any file directly to Discord:
// Send a file
webhook.SetContent("Check out this screenshot!")
.AddFile("screenshot.png")
.Execute();
// Send a buffer as file
webhook.AddBuffer(my_buffer, "game_data.json")
.Execute();
// Send an embed with attatched images
embed.SetTitle("Game Screenshot")
.SetDescription("Latest gameplay")
.SetImageURL("https://example.com/image.png") // Use web image
.SetImageFile("screenshot.png"); // Or use attached file that is included on the webhook
webhook.AddEmbed(embed);Create polls for community engagement:
// Create a poll
poll = new DiscordPoll("What's your favorite feature?", 24, false);
poll.AddAnswer("Embeds", "📋")
.AddAnswer("File Upload", "📎")
.AddAnswer("Polls", "🗳️");
webhook.AddPoll(poll)
.Execute();Edit or delete messages after sending:
// After successful send, you can edit the message
webhook.SetContent("Updated message!")
.Edit();
// Or delete it completely
webhook.Delete();Make your webhook appear as different users:
webhook.SetUser("GameBot", "https://example.com/bot_avatar.png")
.SetContent("Message from custom bot!")
.Execute();Set multiple embeds or fields at once:
// Set multiple embeds at once
embeds_array = [embed1, embed2, embed3];
webhook.SetEmbeds(embeds_array);
// Set multiple fields for an embed
fields_array = [
{name: "Field 1", value: "Value 1", inline: true},
{name: "Field 2", value: "Value 2", inline: false}
];
embed.SetFields(fields_array);- No reaction detection: Webhooks cannot detect when users react to messages they send
- No incoming events: Webhooks are send-only and cannot listen for Discord events
- No self-reactions: Webhooks cannot add reactions to their own messages
For interactive features requiring user input detection, consider using a Discord bot alongside webhooks.
SetURL(url)- Change the webhook URL after creationSetUser(username, avatar_url)- Set custom webhook identitySetContent(content)- Set message text contentSetPayload(payload)- Set raw payload as a struct or a valid JSON stringSetEmbeds(embeds)- Set an array of embeds at onceSetTTS(enabled)- Enable text-to-speechAddEmbed(embed)- Attach rich embedAddPoll(poll)- Attach interactive pollAddFile(filename)- Attach file from diskAddBuffer(buffer, name)- Attach buffer as fileExecute()- Send new messageEdit()- Edit existing messageDelete()- Delete messageAsync(trace)- Process HTTP response with optional debug tracesProcessed()- Check if request completedClear()- Clear all webhook data and reset to initial stateDestroy()- Destroy webhook object and clean up all resources. Use if the webhook created but not executed
SetTitle(title)- Set embed titleSetDescription(description)- Set main textSetFields(fields)- Set multiple fields at once using an arraySetColor(color)- Set sidebar colorSetAuthor(name, icon_url, url)- Set author infoSetURL(url)- Make title clickableSetImageURL(url)- Set large image from URLSetImageFile(filename)- Set large image from attached fileSetThumbnail(url)- Set small corner imageSetFooter(text, icon_url)- Set bottom textSetTimestamp(timestamp)- Set time indicatorAddField(name, value, inline)- Add data field
AddAnswer(text, emoji)- Add poll option with optional emoji (supports both emoji names as strings and emoji IDs as numbers)
