Brant Goings
Brant Goings
DIAdiscord.js - Imagine an app
Created by Brant Goings on 10/4/2023 in #djs-questions
Slash Command Builder Default Option Values
Good morning all! [email protected] node v18.12.0 I'm working w/ SlashCommandBuilder and am trying to figure out how to set a default value for an option (e.g. String, Boolean, etc.) in the event the user doesn't provide a value For example,
...
.addBooleanOption(option =>
option.setName('private')
.setDescription('Post to just you or public')
...
.addBooleanOption(option =>
option.setName('private')
.setDescription('Post to just you or public')
I would want to use something like .setDefault(true) so if the user didn't give anything I could use private to do something like
const private = interaction.options.getBoolean('private')
interaction.reply({content: 'Hello there', ephemeral: private})
const private = interaction.options.getBoolean('private')
interaction.reply({content: 'Hello there', ephemeral: private})
Where it posts an ephemeral post by default unless the user explicitly sets private to false I've also tried logging the value of private with and without user input to see if I can bootleg my way around it but always get null for some reason... Any help would be appreciated! Thanks!
4 replies
DIAdiscord.js - Imagine an app
Created by Brant Goings on 5/2/2023 in #djs-questions
Bot Not Seeing DMs
Hey all, Working w/ DJS 14.8.0 and Node 18.12.0 I've seen a few threads related to this but I'm pretty sure their answers are already implemented in my code and my bot still isn't logging DMs. Anybody feel up to tackling a problem? This is how I'm initializing my client (overkill, probably):
const client = new Client({
disableEveryone: false,
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.User
]
})
const client = new Client({
disableEveryone: false,
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.DirectMessageReactions
],
partials: [
Partials.Message,
Partials.Channel,
Partials.Reaction,
Partials.User
]
})
and this is a snippet of my messageCreate handler:
client.on("messageCreate", async (message) => {
// Check for DM
if (message.channel.type === ChannelType.DM) {
console.log("Got a DM")
if (message.content.includes("help")) {
console.log("Message includes help")
message.reply(helptext)
}
}
})
client.on("messageCreate", async (message) => {
// Check for DM
if (message.channel.type === ChannelType.DM) {
console.log("Got a DM")
if (message.content.includes("help")) {
console.log("Message includes help")
message.reply(helptext)
}
}
})
Several other parts of the messageCreate handler work perfectly fine. It just seems to be the DM portion that doesn't I have also tried message.channel.type === "dm" and similar, but no dice The Message Content Intent Privileged Gateway Intent is enabled on Discord Developer Portal so that can't be it ChatGPT is giving me outdated info so we're out of luck there too Any thoughts? Thanks!
3 replies