This snippet allows you to search Roblox groups by ID throw Discord. It can be useful if you need info about some Roblox group. For more Roblox-related projects check my profile.
// Authenticates you with the API standard library
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
await lib.discord.channels['@0.3.1'].typing.create({
channel_id: `${context.params.event.channel_id}`,
});
// Get string what we will search
let message = context.params.event.content;
let string = parseInt(message.split(' ').slice(1).join(' '));
try {
// make API request
let result = await lib.ropestudio.robloxcore['@0.0.1'].groupSearch({
groupId: string,
});
let testData = result.information.data[0].name
} catch (e) {
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
message_reference: {
message_id: `${context.params.event.id}`,
},
embeds: [
{
type: `rich`,
title: `Error occurred!`,
timestamp: `${context.params.event.timestamp}`,
description: ` Unknown error occurred.`,
color: 0x303136,
image: {
url: `https://images.rbxcdn.com/d66ae37d46e00a1ecacfe9531986690a.jpg`,
height: 0,
width: 0,
},
},
],
});
return;
}
// make API request
let result = await lib.ropestudio.robloxcore['@0.0.1'].groupSearch({
groupId: string,
});
// Check if no error occurred
if (result.information.data[0] != undefined) {
// Create message with all data what Roblox give us back
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
message_reference: {
message_id: `${context.params.event.id}`,
},
embeds: [
{
type: `rich`,
title: `Roblox group search info`,
description: ` Search result for \*${string}\*.`,
color: 0x303136,
fields: [
{
name: `Group name`,
value: `${result.information.data[0].name}`,
},
{
name: `Group description`,
value: result.information.data[0].description || 'No description',
},
{
name: `Group ID`,
value: `${result.information.data[0].id}`,
},
],
image: {
url: `https://images.rbxcdn.com/d66ae37d46e00a1ecacfe9531986690a.jpg`,
height: 0,
width: 0,
},
},
],
});
} else {
await lib.discord.channels['@0.3.0'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
message_reference: {
message_id: `${context.params.event.id}`,
},
embeds: [
{
type: `rich`,
title: `Error occurred!`,
description: ` Unknown error occurred.`,
color: 0x303136,
image: {
url: `https://images.rbxcdn.com/d66ae37d46e00a1ecacfe9531986690a.jpg`,
height: 0,
width: 0,
},
},
],
});
}