Free Game Javascript is part of the code I used to make bots for Discord and any other, that will grab a RSS Feed and modify it to show the game and the link to them.
var tituloJuegos = Feed.newFeedItemMatches.EntryTitle.split(' - ')[0]
var juegos:Array<string> = [], result:string, prov:string
try{
result = Feed.newFeedItemMatches.EntryTitle.split(' - ')[1]
prov = result.replace(/(free|game|on|[^\w\s]|drm)/gi,'').trim().toLowerCase().split(' ')[0]
} catch(err){
prov=""
}
if (tituloJuegos.split(/,| and | & /g).length>1) {
for (let i=0;i<tituloJuegos.split(/,| and | & /g).length;i++){
juegos.push(tituloJuegos.split(/,| and | & /g)[i].trim())
}
} else {
juegos.push(tituloJuegos.trim())
}
const regex = RegExp('https?:\/\/store\.steampowered\.com\/app\/[0-9]+\/*.*?(?=")|https?:\/\/(www\.|store\.)epicgames.com\/.*?(?=")|https?:\/\/(www\.)?humblebundle.com\/store\/.*?(?=")|https?:\/\/(www\.)?gog\.com\/(game\/)?.*?(?=")|https?:\/\/(www\.|.*\.)?ubisoft.com\/.*?(?=")', 'gi');
let preurls:Array<string> = [],url
while ((url = regex.exec(Feed.newFeedItemMatches.EntryContent)) !== null) {
preurls.push(url[0])
}
let urls:Array<string> = []
juegos.forEach(function(valor, x){
let anadido = 0
preurls.forEach(function(value, i){
if(!anadido) {
let regex = RegExp('.*'+valor.toLowerCase().split(" ")[0].replace(/[^\w\s]|_/g,"")+'.*','g'), bool
if((bool = regex.exec(value)) !== null){
urls.push(value)
anadido++
} else if (i===+preurls.length-1) {
if (prov.toLowerCase() === 'steam'||preurls.length===juegos.length) {
urls.push(preurls[x])
anadido++
} else {
urls.push(Feed.newFeedItemMatches.EntryUrl)
anadido++
}
}
}
if(anadido) preurls.splice(i,1); return
})
if(!anadido){
urls.push(Feed.newFeedItemMatches.EntryUrl)
}
})
var color:number = 0,name:string
switch(prov.toLowerCase()){
case 'steam': color=51; break;
case 'epic': color=16448250; break;
case 'uplay': color=6143; break;
case 'gog': color=11075748; prov=prov.toUpperCase(); break;
default: color=63244; break;
}
if (prov!=='') {
name=prov.charAt(0).toUpperCase() + prov.slice(1)+ ' Free Game'
if(juegos.length>1) name=name+'s'
}
var body:string = `{"username":"${name}","content":"||@here|| New free games!", "embeds": [`
for (let i=0;i<juegos.length;i++) {
body += `{"title":"${juegos[i]}","url":"${urls[i]}","color":${color}}`
if(i<juegos.length-1){body += ','}
}
body += ']}'
MakerWebhooks.makeWebRequest.setBody(body)
I use this code with the GrabFreeGames RSS from Steam Announcements, but you can use any you want. ;D
Paste it on your code, modify what you actually need, and be happy. :)