This snippet will automatically list all the slash commands your bot has! There is no need to update the code to list your commands manually. Use the prefix ?help after installing the snippet.
const lib = require('lib')({token: process.env.STDLIB_SECRET_TOKEN});
let commands = await lib.discord.commands['@0.1.1'].list({
guild_id: `${context.params.event.guild_id}`,
with_localizations: false
});
let commandList = [], options;
for(let command of commands){
options = "";
if(command.options){
options = `\n *Options:* \n` + command.options.map(option => {return ` \`${option.name}\` - ${option.description}`})?.join('\n');
}
commandList.push(`${command.name}:${command.id}> - ${command.description}${options}`);
}
if(commandList.length == 0){
return lib.discord.channels['@0.3.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
content: `No slash commands found!`,
message_reference: {message_id: context.params.event.id}
});
}
await lib.discord.channels['@0.3.0'].messages.create({
"channel_id": `${context.params.event.channel_id}`,
"content": "",
"tts": false,
"embeds": [
{
"type": "rich",
"title": `Commands`,
"description": ["Below is the list of `/` commands!",commandList.join('\n\n')].join('\n\n'),
"color": 0xb500ac
}
]
});