New in discord.js

Hello everyone, I'm new in discord.js and i'm trying to make my first bot with slash commands. In the Welcome page (discord.js website) I found a code that worked but not totally. The BOT got the {/} commands badge but I can't use the /ping role with that bot because I can't see it in the list. How can I fix it? Thanks in advance 🙂 CODE:
const { REST, Routes } = require('discord.js');
//
const commands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];

const rest = new REST({ version: '10' }).setToken("TOKEN");
//
(async () => {
try {
console.log('Started refreshing application (/) commands.');

await rest.put(Routes.applicationCommands("1089104043437195294"), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
//
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
//
client.login("TOKEN");
const { REST, Routes } = require('discord.js');
//
const commands = [
{
name: 'ping',
description: 'Replies with Pong!',
},
];

const rest = new REST({ version: '10' }).setToken("TOKEN");
//
(async () => {
try {
console.log('Started refreshing application (/) commands.');

await rest.put(Routes.applicationCommands("1089104043437195294"), { body: commands });

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});
//
client.on('interactionCreate', async interaction => {
if (!interaction.isChatInputCommand()) return;

if (interaction.commandName === 'ping') {
await interaction.reply('Pong!');
}
});
//
client.login("TOKEN");
5 Replies
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Robelo06
Robelo06OP•2y ago
[email protected] node 18.12.1
souji
souji•2y ago
i would heavily suggest, that you reset that bot token, not just edit it out
Robelo06
Robelo06OP•2y ago
I'm doing it right now done you also fixed my "issue" lmao thanks a lot ping is showing now
Unknown User
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server