Bot treating register-commands.js file like its not there.

This is my index.js
require("dotenv").config();
const { Client, IntentsBitField } = require("discord.js");

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});

client.on("ready", (c) => {
console.log(`${c.user.username} is online.`);
});

client.on("interactionCreate", (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName == "ping") {
interaction.reply("Pong!");
}
});

client.login(process.env.TOKEN);
require("dotenv").config();
const { Client, IntentsBitField } = require("discord.js");

const client = new Client({
intents: [
IntentsBitField.Flags.Guilds,
IntentsBitField.Flags.GuildMembers,
IntentsBitField.Flags.GuildMessages,
IntentsBitField.Flags.MessageContent,
],
});

client.on("ready", (c) => {
console.log(`${c.user.username} is online.`);
});

client.on("interactionCreate", (interaction) => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName == "ping") {
interaction.reply("Pong!");
}
});

client.login(process.env.TOKEN);
And this is my register-commands.js
require("dotenv").config();
const { REST, Routes } = require("discord.js");

const commands = [
{
name: "ping",
description: "Replies with Pong!",
},
];

const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);

(async () => {
try {
console.log("Started refreshing application (/) commands.");

await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), {
body: commands,
});

console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
})();
require("dotenv").config();
const { REST, Routes } = require("discord.js");

const commands = [
{
name: "ping",
description: "Replies with Pong!",
},
];

const rest = new REST({ version: "10" }).setToken(process.env.TOKEN);

(async () => {
try {
console.log("Started refreshing application (/) commands.");

await rest.put(Routes.applicationCommands(process.env.CLIENT_ID), {
body: commands,
});

console.log("Successfully reloaded application (/) commands.");
} catch (error) {
console.error(error);
}
})();
It doesn't recognise that the file exists, and im not getting my /ping command in discord
15 Replies
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Panda
PandaOP2y ago
yes i used nodemon it runs src/index.js in the tutorial he didnt mention anything else and it worked so
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Panda
PandaOP2y ago
wouldnt it be node src/register-commands?
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Panda
PandaOP2y ago
isnt there a way to make it refresh with nodemon
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Panda
PandaOP2y ago
everytime
monbrey
monbrey2y ago
What tutorial? Our guide sure as hell mentions it
Panda
PandaOP2y ago
monbrey
monbrey2y ago
Yeah no idea what that is, we dont recommend third party guides
Panda
PandaOP2y ago
Can you send me the link to your guide?
d.js docs
d.js docs2y ago
guide Creating Your Bot: Registering slash commands read more
monbrey
monbrey2y ago
Their code is a copy of ours anyway
Panda
PandaOP2y ago
fair enough well thanks ill just follow this from now on then
Want results from more Discord servers?
Add your server