Get minecraft block info in discord like https://media.discordapp.net/attachments/949907682352050250/949935995476934687/testing-1_-_Google_Chrome_06-03-2022_13_14_40.png?width=650&height=606
// authenticates you with the API standard library
// type `await lib.` to display API autocomplete
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
const args = context.params.event.content.split(' ').slice(1);
if (!args.length) {
return lib.discord.channels['@release'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: `No name provided.`,
});
} else {
let result = await lib['minecraft-api'].minecraft['@2.0.0'].Minecraft.Block['Block-find']({
block_name: `${args}`, // required
});
if (!result.error) {
await lib.discord.channels['@release'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
embeds: [
{
type: 'rich',
title: '',
description: `π **Display Name:** ${result.displayName}
π§βπ **Name:** ${result.name}
π³ **ID:** ${result.id}
π¨ **Hardness:** ${result.hardness}
π‘οΈ **Resistance:** ${result.resistance}
βοΈ **Diggable:** ${result.diggable}
πͺ **Transparent:** ${result.transparent}
π‘ **FilterLight:** ${result.filterLight}
π‘ **EmitLight:** ${result.emitLight}
π¦ **Stack Size:** ${result.stackSize}
πͺ΅ **Material:** ${result.material}`,
color: 0x08eeee,
image: {
url: `https://cdn.discordapp.com/attachments/930084368003772438/949924579336405012/E1w6YsnVEAEn7Ro.jpg`,
height: 0,
width: 0,
},
thumbnail: {
url: `https://cdn.discordapp.com/attachments/930084368003772438/949922915678306344/latest.png`,
height: 0,
width: 0,
},
},
],
});
} else {
await lib.discord.channels['@release'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
embeds: [
{
type: 'rich',
title: '',
description: `\`\`\`js\nError: No results found for \`${args}\` \`\`\``,
color: 0xff0000,
},
],
});
}
}