Gets the steam information for a game. Preview: https://media.discordapp.net/attachments/933749024161398804/939863575395172392/unknown.png
// Get's a steam game's info
// Setup:
// Create a command in https://autocode.com/tools/discord/command-builder/
// Name it "steam"
// Create a "string" option called "game"
// That's all.
// Preview: https://media.discordapp.net/attachments/933749024161398804/939863575395172392/unknown.png
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
// urlify the game
let query = context.params.event.data.options[0].value.replace(/\s/g, "%20")
// get game info
let result = await lib.http.request['@1.1.6'].get({
url: `https://api.popcat.xyz/steam?q=${query}`
});
// if the game doesn't exist
if (typeof result.data.banner == 'undefined') {
await lib.discord.channels['@0.2.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": "",
"tts": false,
"embeds": [
{
"type": "rich",
"title": `โ Game not found`,
"description": "",
"color": 0xe74c3c
}
]
});
}
else {
// add spaces between developer names
let dev = `${result.data.developers}`
let devs = dev.replace(/,/g, ", ")
// send the data
await lib.discord.channels['@0.2.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": "",
"tts": false,
"embeds": [
{
"type": "rich",
"title": `${result.data.name}`,
"description": `${result.data.description}`,
"color": 0x34495e,
"fields": [
{
"name": `๐ฎ Controller Support:`,
"value": `${result.data.controller_support}`
},
{
"name": `๐จโ๐ป Developers:`,
"value": `${devs}`
},
{
"name": `๐ข Publishers`,
"value": `${result.data.publishers}`
},
{
"name": `:moneybag: Price`,
"value": `${result.data.price}`
}
],
"image": {
"url": `${result.data.banner}`,
"height": 0,
"width": 0
},
"thumbnail": {
"url": `${result.data.thumbnail}`,
"height": 0,
"width": 0
},
"url": `${result.data.website}`
}
]
});
}