Omar
Omar
DIAdiscord.js - Imagine an app
Created by Omar on 9/19/2024 in #djs-questions
kick/ban member in list of servers
why it only kicks from the server i used the command at? the guilds id are consoled correctly
async execute(interaction) {
const user = interaction.options.getUser("user");

for (const guildID of process.env.GUILDS.split(",")) {
console.log(guildID)
const guild = await interaction.guild.fetch(guildID)

await guild.members.kick(user);
}

await interaction.reply(`Kicked ${user.tag}`);
},
async execute(interaction) {
const user = interaction.options.getUser("user");

for (const guildID of process.env.GUILDS.split(",")) {
console.log(guildID)
const guild = await interaction.guild.fetch(guildID)

await guild.members.kick(user);
}

await interaction.reply(`Kicked ${user.tag}`);
},
4 replies
DIAdiscord.js - Imagine an app
Created by Omar on 9/15/2024 in #djs-questions
slash command issue
I have command called /ping and its loaded correctly but my bot is not showing/can't it
const commandFolders = fs.readdirSync("./commands");

for (const folder of commandFolders) {
const filePath = path.join("./commands", folder);
const commandFiles = fs
.readdirSync(filePath)
.filter((file) => file.endsWith(".js"));

for (const file of commandFiles) {
try {
let command = await import(`./commands/${folder}/${file}`); // Use dynamic import
command = command.default;

if (command.data && command.execute) {
client.commands.set(command.data.name, command);
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
);
}
} catch (error) {
console.error(`[ERROR] Failed to load command ${filePath}: ${error}`);
}
}
}
const commandFolders = fs.readdirSync("./commands");

for (const folder of commandFolders) {
const filePath = path.join("./commands", folder);
const commandFiles = fs
.readdirSync(filePath)
.filter((file) => file.endsWith(".js"));

for (const file of commandFiles) {
try {
let command = await import(`./commands/${folder}/${file}`); // Use dynamic import
command = command.default;

if (command.data && command.execute) {
client.commands.set(command.data.name, command);
} else {
console.log(
`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`
);
}
} catch (error) {
console.error(`[ERROR] Failed to load command ${filePath}: ${error}`);
}
}
}
25 replies