FirasRG
FirasRG
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by FirasRG on 6/23/2024 in #djs-questions
Duplicated commands (not global)
Gonna check that out
9 replies
DIAdiscord.js - Imagine an app
Created by FirasRG on 6/23/2024 in #djs-questions
Duplicated commands (not global)
Ah thanks
9 replies
DIAdiscord.js - Imagine an app
Created by FirasRG on 6/23/2024 in #djs-questions
Duplicated commands (not global)
this is my deploy-commands.ts
const commands = [] as Command[];

const foldersPath = path.join(__dirname, 'src/commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {

const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.ts'));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

const rest = new REST().setToken(token);

(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
) as unknown[];

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {

console.error(error);
}
})();
const commands = [] as Command[];

const foldersPath = path.join(__dirname, 'src/commands');
const commandFolders = fs.readdirSync(foldersPath);

for (const folder of commandFolders) {

const commandsPath = path.join(foldersPath, folder);
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.ts'));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
if ('data' in command && 'execute' in command) {
commands.push(command.data.toJSON());
} else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}
}

const rest = new REST().setToken(token);

(async () => {
try {
console.log(`Started refreshing ${commands.length} application (/) commands.`);

const data = await rest.put(
Routes.applicationGuildCommands(clientId, guildId),
{ body: commands },
) as unknown[];

console.log(`Successfully reloaded ${data.length} application (/) commands.`);
} catch (error) {

console.error(error);
}
})();
9 replies
DIAdiscord.js - Imagine an app
Created by FirasRG on 6/23/2024 in #djs-questions
Duplicated commands (not global)
fyi, when i kick the bot from the server and readd it, the command appears once !
9 replies