Teixeira
Teixeira
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/28/2023 in #djs-questions
Setting autocomplete options based on other option's value
Sadge... Alright thank you
11 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/28/2023 in #djs-questions
Setting autocomplete options based on other option's value
private async _autocompleteAddItem(interaction: Subcommand.AutocompleteInteraction) {
const focusedOption = interaction.options.getFocused(true);
let autocompleteChoices: ApplicationCommandOptionChoiceData<string>[];

if (focusedOption.name === 'type') {
autocompleteChoices = [
{
name: 'Please select an item category first.',
value: 'invalid'
}
];

const itemCategoryIdentifier = interaction.options.getString('category');

if (itemCategoryIdentifier) {
const itemCategory = this.container.application.shops.itemCategories.find(
(itemCategory) => itemCategory.identifier === itemCategoryIdentifier
);

if (!itemCategory) {
throw new TypeError(`Unknown item category identifier ${itemCategoryIdentifier}`);
}

autocompleteChoices = itemCategory.types.map((type) => {
const { name, identifier } = type;

return {
name,
value: identifier
};
});
}
} else {
throw new TypeError(`Unknown autocomplete option "${focusedOption.name}"`);
}

const query = focusedOption.value;
await interaction.respond(new AutocompleteQuery(autocompleteChoices, query).results);
}
private async _autocompleteAddItem(interaction: Subcommand.AutocompleteInteraction) {
const focusedOption = interaction.options.getFocused(true);
let autocompleteChoices: ApplicationCommandOptionChoiceData<string>[];

if (focusedOption.name === 'type') {
autocompleteChoices = [
{
name: 'Please select an item category first.',
value: 'invalid'
}
];

const itemCategoryIdentifier = interaction.options.getString('category');

if (itemCategoryIdentifier) {
const itemCategory = this.container.application.shops.itemCategories.find(
(itemCategory) => itemCategory.identifier === itemCategoryIdentifier
);

if (!itemCategory) {
throw new TypeError(`Unknown item category identifier ${itemCategoryIdentifier}`);
}

autocompleteChoices = itemCategory.types.map((type) => {
const { name, identifier } = type;

return {
name,
value: identifier
};
});
}
} else {
throw new TypeError(`Unknown autocomplete option "${focusedOption.name}"`);
}

const query = focusedOption.value;
await interaction.respond(new AutocompleteQuery(autocompleteChoices, query).results);
}
11 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/28/2023 in #djs-questions
Setting autocomplete options based on other option's value
I'm not being able to add the code to the original post can I just send it as a new message here
11 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/28/2023 in #djs-questions
Setting autocomplete options based on other option's value
[email protected] node v18.16.0
11 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/28/2023 in #djs-questions
Setting autocomplete options based on other option's value
I added this at the end of the post
11 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/23/2023 in #djs-questions
Is there any way to know when a user has purchased or cancelled/not renewed a server subscription?
It's not available here either (Portugal), are you sure it gives a role when a user subcribes to it?
24 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 6/23/2023 in #djs-questions
Is there any way to know when a user has purchased or cancelled/not renewed a server subscription?
24 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 8/12/2022 in #djs-questions
Cannot use GIF url as an embed's image.
Yep I just double checked and I had done everything correctly, when I tried that way it didn't even show the blank square, the embed would have no image at all
9 replies
DIAdiscord.js - Imagine an app
Created by Teixeira on 8/12/2022 in #djs-questions
Cannot use GIF url as an embed's image.
Node version: 16.16.0 d.js version: 14.0.3
9 replies