Araraura
Araraura
DIAdiscord.js - Imagine a bot
Created by Araraura on 11/2/2023 in #djs-questions
Reply to the original command on a second message
No description
4 replies
DIAdiscord.js - Imagine a bot
Created by Araraura on 3/13/2023 in #djs-questions
Space appears before a new line only on mobile
5 replies
DIAdiscord.js - Imagine a bot
Created by Araraura on 3/3/2023 in #djs-questions
Changing command options doesn't update autocomplete
I have a bt with some commands that take 3 arguments (for example /help [category] [subcategory]) when selecting a category, subcategories will be displayed depending on what category the user has picked by using autocompletion. However, if the user goes back and changes the category to something else, the subcategories won't update according to the new category the user has selected. Is there a way to fix this? I'm not sure if this is a discord issue or a coding issue. My code looks something like this:
@SlashChoice(...tabletAreas)
@SlashOption({
type: ApplicationCommandOptionType.String,
name: "area",
description: "The area of the Lore Tablet",
required: true,
})
area: string,
@SlashOption({
autocomplete: async (interaction: AutocompleteInteraction) => {
const ChosenArea = interaction.options.getString("area");
const tabletNameAutocomplete: { name: string; value: string; }[] = [];
for (const tabletName of tabletList) {
if (tabletName.area === ChosenArea) {
tabletNameAutocomplete.push({ name: tabletName.name, value: tabletName.name });
}
}
const filtered = tabletNameAutocomplete.filter((c: { name: string; }) => capitalize(c.name).startsWith(capitalize(interaction.options.getFocused())));
await interaction.respond(
filtered.map(choice => ({ name: choice.name, value: choice.name })).slice(0, 25)
);
},
type: ApplicationCommandOptionType.String,
name: "name",
description: "The name of the Lore Tablet",
required: true,
})
@SlashChoice(...tabletAreas)
@SlashOption({
type: ApplicationCommandOptionType.String,
name: "area",
description: "The area of the Lore Tablet",
required: true,
})
area: string,
@SlashOption({
autocomplete: async (interaction: AutocompleteInteraction) => {
const ChosenArea = interaction.options.getString("area");
const tabletNameAutocomplete: { name: string; value: string; }[] = [];
for (const tabletName of tabletList) {
if (tabletName.area === ChosenArea) {
tabletNameAutocomplete.push({ name: tabletName.name, value: tabletName.name });
}
}
const filtered = tabletNameAutocomplete.filter((c: { name: string; }) => capitalize(c.name).startsWith(capitalize(interaction.options.getFocused())));
await interaction.respond(
filtered.map(choice => ({ name: choice.name, value: choice.name })).slice(0, 25)
);
},
type: ApplicationCommandOptionType.String,
name: "name",
description: "The name of the Lore Tablet",
required: true,
})
3 replies
DIAdiscord.js - Imagine a bot
Created by Araraura on 3/2/2023 in #djs-questions
Reply to the command author on a 2nd message
Hello, I have a bot that sends the user a message with a button, and if the user who made the command clicks that button, the bot will send another message. Is it possible to have the 2nd message be a reply to the original command the user made? (with how it shows which user made the command and what the command was exactly)
2 replies
DIAdiscord.js - Imagine a bot
Created by Araraura on 2/27/2023 in #djs-questions
Loading slash choices from file
Hello, I want to create a bot that can load a big number of slash command choices from a JSON or CSV file, add them into a collection and automatically add them to a slash command on run. How can I achieve something like that? So far I've only seeing people hard-coding choices in their bots, so if this is possible then I'd like to know how.
11 replies
DIAdiscord.js - Imagine a bot
Created by Araraura on 2/6/2023 in #djs-questions
Fetch user that isn't in current server
How do I fetch a user that's not in the same server as my bot? This is for a command that will display an embed with the user's name (as well as some other stuff), but I'm not sure how to do it. I was able to do that in some of my other commands because it took a User object as a slash command option, but since this particular command that I'm writing now doesn't do that, I'm not sure how to fetch it.
const displayUserInfo = (userId: string) => new EmbedBuilder()
.setTitle(`Displaying info for ${//fetch user here using userId somehow}`)
const displayUserInfo = (userId: string) => new EmbedBuilder()
.setTitle(`Displaying info for ${//fetch user here using userId somehow}`)
Using discord.js 14.7.1 with node.js 19.6.0
13 replies
DIAdiscord.js - Imagine a bot
Created by Araraura on 2/4/2023 in #djs-questions
Can't fetch owner on guild join
I'm trying to fetch the guild owner and send them a message when my bot joins, but my bot is giving me errors: The syntax is discordx, but the problem is still in the regular discord.js lines:
@On({ event: "guildCreate" })
async newServer(guild: Guild) {
const guildOwner = await guild.members.fetch(guild.ownerId); // TypeError: Cannot read properties of undefined (reading 'fetch')
await guildOwner.send(welcomeMessage(guild.name));
@On({ event: "guildCreate" })
async newServer(guild: Guild) {
const guildOwner = await guild.members.fetch(guild.ownerId); // TypeError: Cannot read properties of undefined (reading 'fetch')
await guildOwner.send(welcomeMessage(guild.name));
I also tried using guild.fetchOwner but that gave me guild.fetchOwner is not a function
3 replies