mirror of
https://github.com/artiemis/artemis.js.git
synced 2026-02-14 10:21:54 +00:00
wiktionary improvements
This commit is contained in:
parent
cf61068a28
commit
dfda1c85f7
@ -40,7 +40,7 @@ export default defineCommand({
|
|||||||
const choices = suggestions
|
const choices = suggestions
|
||||||
.map((suggestion) => ({
|
.map((suggestion) => ({
|
||||||
name: suggestion.title,
|
name: suggestion.title,
|
||||||
value: suggestion.key,
|
value: `:${suggestion.key}`,
|
||||||
}))
|
}))
|
||||||
.slice(0, 25);
|
.slice(0, 25);
|
||||||
|
|
||||||
@ -48,7 +48,18 @@ export default defineCommand({
|
|||||||
},
|
},
|
||||||
|
|
||||||
async execute(interaction) {
|
async execute(interaction) {
|
||||||
const term = interaction.options.getString("term", true);
|
let term = interaction.options.getString("term", true);
|
||||||
|
|
||||||
|
// autocomplete value vs user value
|
||||||
|
if (term.startsWith(":")) {
|
||||||
|
term = term.slice(1);
|
||||||
|
} else {
|
||||||
|
const suggestions = await getSuggestions(term);
|
||||||
|
if (!suggestions) {
|
||||||
|
abort("No definitions found");
|
||||||
|
}
|
||||||
|
term = suggestions[0].key;
|
||||||
|
}
|
||||||
|
|
||||||
const definitions = await getDefinitions(term);
|
const definitions = await getDefinitions(term);
|
||||||
if (!definitions?.length) {
|
if (!definitions?.length) {
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user