Custome Minecraft Advancement Command! Do /advancement and fill in info to get a custom advancement! Example: https://media.discordapp.net/attachments/949907682112987145/949973973876232232/general_-_Google_Chrome_06-03-2022_15_46_53.png?width=1440&height=348 Simply run the code and the command will be created. Enjoy! NOTE:global commands take upto an hour to register because Discord has to check it on every server.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let firstCheck = await lib.utils.kv['@release'].get({
key: `AdvancementCommand-Check`,
defaultValue: true,
});
if (firstCheck) {
await lib.discord.commands['@release'].create({
"name": "advancement",
"description": "Create a custom Minecraft Advancement",
"options": [
{
"type": 3,
"name": "block",
"description": "Name of the block you want to use",
"required": true
},
{
"type": 3,
"name": "title",
"description": "Title of the advancement",
"required": true
},
{
"type": 3,
"name": "text",
"description": "Text to use in the advancement",
"required": true
}
]
});
await lib.utils.kv['@release'].set({
key: `AdvancementCommand-Check`,
value: false,
});
return 'Slash command created successfully';
}
if (context.params.event.id === '0000000000000000') {
return 'Please run the slash command from Discord';
}
let block = context.params.event.data.options[0].value;
let title = context.params.event.data.options[1].value;
let text = context.params.event.data.options[2].value;
let result = await lib['minecraft-api'].minecraft['@2.0.0'].Other.Advancements.Custom({
block: block, // required
title: title, // required
text: text, // required
});
let imgRequest = await lib.http.request['@1.1.6']({
method: 'GET',
url: `${result.link}`
});
if (imgRequest.headers['content-type'].includes('image')) {
await lib.discord.channels['@release'].messages.create({
channel_id: context.params.event.channel_id,
content: `${result.link}`
});
}else {
await lib.discord.channels['@release'].messages.create({
channel_id: `${context.params.event.channel_id}`,
content: ``,
embeds: [
{
type: 'rich',
title: '',
description: `\`\`\`js\nError: Your info could not be converted to image.\`\`\``,
color: 0xff0000,
},
],
});
}