[ WEBHOOKS ] How to use Cloudflare Workers for sending Discord Messages

git
I had this code sitting around so I thought I would share it.

Before I continue with the tutorial, I should note that this code does not have a rate limiting function, so use this only as a guide of how everything works. You will need ratelimiting or else your discord account could be banned if your sending too many requests.

  1. Navigate to your discord server and create a Discord Webhook and copy the URL.
  2. Go to Cloudflare > Workers > Create a Worker and create one.
  3. Visit this repo and copy the code named cloudflare.java into your worker. Change the discordWebhookUrl to yours and deploy the code.
  4. All finished! To test out your Discord Webhook, try this example script. It sends a message whenever a player joins the game. The webhook needs a author, message, and color field to send.

If everything works, you should see something like this in your discord channel!

image

This is my first tutorial, so please leave some feedback!

Thanks for reading,

8 Likes

cool resource, but i keep getting the default cloudflare return, that being hello world

Sorry for not being clear in the post, but you need to deploy the code using this button

nice tutorial, similar to this one!
you might want to add some details about what cloudflare is and how to sign up.

also quick note - it doesn’t affect the file contents, but a javascript file ends in .js, not .java :‎)

1 Like

took a few tries hitting deploy for it to work, modified it to allow me to fully customize what is sent, can also pass an image id, and it will get the image from roblox and add it to the embed

image

really good for a global shop update channel!

1 Like