Whisperer
Whisperer
DIAdiscord.js - Imagine an app
Created by Whisperer on 9/11/2024 in #djs-questions
Searching discord.js Documentation
I'm trying to make a slash command to get documentation on specific topics on discord.js, however I don't know how lol
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('docs')
.setDescription('Search discord.js documentation!')
.addStringOption(option =>
option.setName('query')
.setDescription('Phrase to search for')
.setAutocomplete(true)),

async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused();
const choices = ['Popular Topics: Threads', 'Sharding: Getting started', 'Library: Voice Connections', 'Interactions: Replying to slash commands', 'Popular Topics: Embed preview'];
const filtered = choices.filter(choice => choice.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
},

async code(interaction) {

},
};
const { SlashCommandBuilder } = require('discord.js');

module.exports = {
data: new SlashCommandBuilder()
.setName('docs')
.setDescription('Search discord.js documentation!')
.addStringOption(option =>
option.setName('query')
.setDescription('Phrase to search for')
.setAutocomplete(true)),

async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused();
const choices = ['Popular Topics: Threads', 'Sharding: Getting started', 'Library: Voice Connections', 'Interactions: Replying to slash commands', 'Popular Topics: Embed preview'];
const filtered = choices.filter(choice => choice.startsWith(focusedValue));
await interaction.respond(
filtered.map(choice => ({ name: choice, value: choice })),
);
},

async code(interaction) {

},
};
This is what i've got so far ( from discord.js documentation)
6 replies