constt 🎄❄
constt 🎄❄
DIAdiscord.js - Imagine a bot
Created by constt 🎄❄ on 10/5/2024 in #djs-questions
duration is null or undefined
when i do /addreminder 1s it just still says its undefined.
const { SlashCommandBuilder } = require("discord.js");
const ms = require("ms");

module.exports = {
data: new SlashCommandBuilder()
.setName("addreminder")
.setDescription("Adds a reminder")
.addStringOption((option) =>
option
.setName("duration")
.setDescription("When to remind you (e.g., 10s, 5m, 1h)")
.setRequired(true)
),
async execute(interaction) {
const duration = interaction.options.getString("duration");

if (!duration) {
console.error("Error: duration is null or undefined!!");
return interaction.reply({
content:
"No duration provided! Please provide a valid duration (e.g., 10s, 5m, 1h).",
ephemeral: true,
});
}

const msDuration = ms(duration);

if (!msDuration || isNaN(msDuration) || msDuration <= 0) {
return interaction.reply({
content:
"Invalid duration! Please provide a valid format (e.g., 10s, 5m, 1h).",
ephemeral: true,
});
}

return interaction.reply({
content: `Reminder set for ${duration}!`,
ephemeral: true,
});
},
};
const { SlashCommandBuilder } = require("discord.js");
const ms = require("ms");

module.exports = {
data: new SlashCommandBuilder()
.setName("addreminder")
.setDescription("Adds a reminder")
.addStringOption((option) =>
option
.setName("duration")
.setDescription("When to remind you (e.g., 10s, 5m, 1h)")
.setRequired(true)
),
async execute(interaction) {
const duration = interaction.options.getString("duration");

if (!duration) {
console.error("Error: duration is null or undefined!!");
return interaction.reply({
content:
"No duration provided! Please provide a valid duration (e.g., 10s, 5m, 1h).",
ephemeral: true,
});
}

const msDuration = ms(duration);

if (!msDuration || isNaN(msDuration) || msDuration <= 0) {
return interaction.reply({
content:
"Invalid duration! Please provide a valid format (e.g., 10s, 5m, 1h).",
ephemeral: true,
});
}

return interaction.reply({
content: `Reminder set for ${duration}!`,
ephemeral: true,
});
},
};
7 replies
DIAdiscord.js - Imagine a bot
Created by constt 🎄❄ on 10/4/2024 in #djs-questions
register commands for multiple servers
i got the code for my command register file from the docs. there you need to input a guild id, but what if you can add my bot to multiple discord servers then i cant just all copy in ids right? how would i do that? is there a way to like globaly register commands?
22 replies
DIAdiscord.js - Imagine a bot
Created by constt 🎄❄ on 5/13/2024 in #djs-questions
delete channels
How do i delete channels fast? Becausen when you normally make a loop and delete channels its kinda slow
33 replies