Skip to content

Instantly share code, notes, and snippets.

@182exe
Last active April 11, 2024 05:29
Show Gist options
  • Save 182exe/81fbaac54d2aef8fece2580e4a4bc80c to your computer and use it in GitHub Desktop.
Save 182exe/81fbaac54d2aef8fece2580e4a4bc80c to your computer and use it in GitHub Desktop.
discord - simple webhook message edit (nodejs, axios)
const axios = require('axios');
const url = `https://discord.com/api/webhooks/<webhookid>/<webhooktoken>`
// initially post a message
// "?wait=true" url param tells discord to return a message object so we can get the id of it
axios.post(`${url}?wait=true`, {
content: "hi, test. this is the first message."
}).then((response) => {
// use PATCH method to edit webhooks
axios.patch(`${url}/messages/${response.data.id}`, {content: "edit?"})
});
// references:
// https://discord.com/developers/docs/resources/webhook#edit-webhook-message
// https://birdie0.github.io/discord-webhooks-guide/other/edit_webhook_message.html
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment