I’m just gonna get straight to the point: How would I make a webhook from the DevForum to Discord. Like, instead of Roblox to Discord, I’d use DevForum to Discord.
I want to make a webhook that posts DevForum announcements automatically in one of the channels in a server.
I know its possible because I’ve seen another server do it.
Can someone please tell me how I could do this?
Just post what the DevForum says, or have a bot do it. Since the DevForums isn’t a game, you can’t really have a ‘proxy’ to send messages, you need a bot to get the info and send it to the server.
It’s not as straightforward as Roblox Servers to Discord, but is definitely possible.
Note: This belongs in #help-and-feedback:scripting-support
Java, more Java, some JavaScript (possibly), and Java!
All jokes aside, you’d need to get a request, using a 3rd party, then take the request, and send it to discord and post it. That’s probably the best way to explain it, but since I’ve never done it, I don’t have any links sadly.
Um. Can you further elaborate on that? I still don’t fully understand.
EDIT: Check my reply below
You would not be able to do it in Roblox. You would have to use another programming language, such as Java or Node.js (JavaScript). Once you have chosen a language, you must then run a cron job (a ‘script’ that runs whenever you set it to, e.g. daily at 3:00pm) that makes a HTTP GET request to the announcements category and parses the HTML. From there, get all the new articles (you could maybe do this by checking when they were published and comparing them to when the cron last ran?) and get the link, then send it to a webhook.
Here are some packages that should help (Node.js):
Sorry about the format. I’m on mobile.
Actually, after further research it seems that there is a Discourse (the software roblox uses for the forum) API, so just use that rather than parsing the HTML. Will be quicker + futureproof. Here’s a link: https://docs.discourse.org/
1 Like
Thanks!
I’ll take a look at the Documentation that you linked.
Alr, I know it 8 hours later, but I found a way to get all the topics.
You can’t do this with webhooks, instead, bots.
Basically we use the thing the cool kids call “JSON”
Now I assume you have node.js, discord.js, and node-fetch installed.
This is the script:
const { Client, Intents, MessageEmbed, TextChannel } = require('discord.js');
const fetch = require('node-fetch');
const client = new Client({ intents: [Intents.FLAGS.GUILDS, Intents.FLAGS.GUILD_MESSAGES] });
async function getLatestPosts() {
await fetch('https://devforum.roblox.com/c/bulletin-board/63.json')
.then(res => res.json())
.then(function(data){
let notificationChannel = client.channels.cache.get('949099990389755996') // channel ID here
let topicList = data.topic_list;
let topics = topicList.topics;
// read each topic
topics.forEach(topic => {
let createdAt = topic.created_at;
let date = new Date();
// embed data
let id = topic.id // topic id
let title = topic.title
// check if the topic was created today
let currentDay = date.getUTCDate();
let currentMonth = date.getUTCMonth() + 1;
let currentYear = date.getUTCFullYear();
// get created at args
let timeArgs = createdAt.split("-") // split the created at string to get each arg
let createdDay = timeArgs[2];
let createdMonth = timeArgs[1];
let createdYear = timeArgs[0]
createdDay = createdDay.split("T")[0] // seperate the rest of the time to get ONLY the day
console.log(createdMonth, currentMonth)
// now check if the topic was created today
//currentDay === createdDay && currentMonth === createdMonth && currentYear === createdYear
if (currentDay == createdDay && currentMonth == createdMonth && currentYear == createdYear)
{
console.log('passed thru check')
// add embed
const embedData = {
color: "#f50404",
author: {
name: 'New Roblox Update!',
url: `https://devforum.roblox.com/t/${id}`,
},
fields: [
{
name: title,
value: "ROBLOX UPDATE BABYYYYYY"
}
]
}
// send embed
notificationChannel.send({ embeds: [embedData] });
}
setTimeout(() => {}, 1000);// add a 1 second delay per checks
});
})
}
client.once('ready', () => {
getLatestPosts()
});
client.login('TOKENHERE'); // log bot in
For testing I put it as bulletin board. But for announcements change that to
https://devforum.roblox.com/c/updates/announcements/36.json
then just run node JAVASCRIPTFILENAMEHERE
For constant checking, you can make the getLatestPost function in a while loops. Anyways, if u have any questions feel free to ask
@ValiantWind
2 Likes