Beat.
Beat.
DIAdiscord.js - Imagine a bot
Created by Beat. on 5/6/2024 in #djs-questions
Only enabling certain users to answer a poll
Looking at the PR the only data given from the vote added and vote removed listener is the answer and userId. I'm trying to think of ways where only a role could respond to the active poll but even using a db I don't see any possibilities since the listener does not give a lot of information to work with. Does anyone have any ideas?
5 replies
DIAdiscord.js - Imagine a bot
Created by Beat. on 5/4/2024 in #djs-questions
Use new poll feature
14.15.1 introduced allows bots to use discord's poll system but I can't seem to find a how to anywhere. A link would be most helpful.
3 replies
DIAdiscord.js - Imagine a bot
Created by Beat. on 2/29/2024 in #djs-questions
Unsuccessful implementation of autocomplete with subcommands
Here is the abridged code command file
module.exports = {
data: new SlashCommandBuilder().setName('getnextevent')
.setDescription('get the next event for the indicated team')
.addSubcommand(subcommand =>
subcommand.setName('nba').setDescription('National Basketball Association')
.addStringOption(option =>
option.setName('team').setDescription('the name of the team').setRequired(true).setAutocomplete(true))),
async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused(true);
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 })),
);
}
}
module.exports = {
data: new SlashCommandBuilder().setName('getnextevent')
.setDescription('get the next event for the indicated team')
.addSubcommand(subcommand =>
subcommand.setName('nba').setDescription('National Basketball Association')
.addStringOption(option =>
option.setName('team').setDescription('the name of the team').setRequired(true).setAutocomplete(true))),
async autocomplete(interaction) {
const focusedValue = interaction.options.getFocused(true);
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 })),
);
}
}
index.js
if (interaction.isAutocomplete()) {
await command.autocomplete(interaction);
} else {
await command.execute(interaction, conn);
}
if (interaction.isAutocomplete()) {
await command.autocomplete(interaction);
} else {
await command.execute(interaction, conn);
}
I have console logs in the autocomplete function that are not firing so I don't understand what is going on. In my command handler I also have a log for the interaction which is also not firing.
13 replies
DIAdiscord.js - Imagine a bot
Created by Beat. on 3/26/2023 in #djs-questions
should I use Sapphire.js?
I used to use discord.js commando on my discord bot and learned a while ago that its deprecated. I see that sapphire.js has propped up in its place. I want to upgrade my discord to latest and so a lot of my stuff is going to break. As a result, since I have to do a refactor, I'm left with a choice now of either migrating to sapphire.js or removing the framework and sticking with plain old discord.js. I've visited the site and the reasons listed as to what it offers aren't super specific and from reading doesn't seem like it offers anything that discord.js doesn't already. Is someone able to comment on this and give their two cents on why someone should or should not use sapphire.js?
2 replies