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.
- Navigate to your discord server and create a
Discord Webhook
and copy the URL. - Go to
Cloudflare > Workers > Create a Worker
and create one. - Visit this repo and copy the code named
cloudflare.java
into your worker. Change thediscordWebhookUrl
to yours and deploy the code. - 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
, andcolor
field to send.
If everything works, you should see something like this in your discord channel!
This is my first tutorial, so please leave some feedback!
Thanks for reading,