Edits history of script submission #22357 for ' Edit message (discord)'

  • bunnative
    One script reply has been approved by the moderators
    Ap­pro­ved
    //native
    
    type DiscordWebhook = {
      webhook_url: string;
    };
    export async function main(
      discord_webhook: DiscordWebhook,
      messageId: string,
      newMessageContent: string,
    ) {
      const response = await fetch(
        `${discord_webhook.webhook_url}/messages/${messageId}`,
        {
          method: "PATCH",
          headers: {
            "Content-Type": "application/json",
          },
          body: JSON.stringify({ content: newMessageContent }),
        },
      );
      if (!response.ok) {
        throw new Error(`${response.status} ${await response.text()}`);
      }
      return await response.json();
    }
    

    Submitted by hugo989 17 days ago