Problem w my /ping Slash command

So idk why my /ping dosnt work, that shows this error, if anyone can help me that would be great thanks
18 Replies
d.js toolkit
d.js toolkit17mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Post the full error stack trace, not just the top part! - Show your code! - Explain what exactly your issue is. - Not a discord.js issue? Check out #useful-servers. - Issue solved? Press the button!
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
s a k a  t a
s a k a t aOP17mo ago
ChatInputCommandInteraction {
type: 2,
id: '1133160758394495177',
applicationId: '1132442679737864287',
channelId: '1132378959460438026',
guildId: '775306869978824714',
user: User {
id: '525790133937635378',
bot: false,
system: false,
flags: UserFlagsBitField { bitfield: 128 },
username: 'sakatanoraj',
discriminator: '0',
avatar: 'f3bd2ed87d413d837594ff455a105d59',
banner: undefined,
accentColor: undefined
},
member: GuildMember {
guild: Guild {
id: '775306869978824714',
name: '[AEY]',
icon: 'a_c6b2474be4ceb5478bc0a927afa92a43',
features: [Array],
commands: [GuildApplicationCommandManager],
members: [GuildMemberManager],
channels: [GuildChannelManager],
bans: [GuildBanManager],
roles: [RoleManager],
presences: PresenceManager {},
voiceStates: [VoiceStateManager],
stageInstances: [StageInstanceManager],
invites: [GuildInviteManager],
scheduledEvents: [GuildScheduledEventManager],
autoModerationRules:
ChatInputCommandInteraction {
type: 2,
id: '1133160758394495177',
applicationId: '1132442679737864287',
channelId: '1132378959460438026',
guildId: '775306869978824714',
user: User {
id: '525790133937635378',
bot: false,
system: false,
flags: UserFlagsBitField { bitfield: 128 },
username: 'sakatanoraj',
discriminator: '0',
avatar: 'f3bd2ed87d413d837594ff455a105d59',
banner: undefined,
accentColor: undefined
},
member: GuildMember {
guild: Guild {
id: '775306869978824714',
name: '[AEY]',
icon: 'a_c6b2474be4ceb5478bc0a927afa92a43',
features: [Array],
commands: [GuildApplicationCommandManager],
members: [GuildMemberManager],
channels: [GuildChannelManager],
bans: [GuildBanManager],
roles: [RoleManager],
presences: PresenceManager {},
voiceStates: [VoiceStateManager],
stageInstances: [StageInstanceManager],
invites: [GuildInviteManager],
scheduledEvents: [GuildScheduledEventManager],
autoModerationRules:
[AutoModerationRuleManager],
available: true,
shardId: 0,
splash: null,
banner: null,
description: null,
verificationLevel: 2,
vanityURLCode: null,
nsfwLevel: 0,
premiumSubscriptionCount: 2,
discoverySplash: null,
memberCount: 14,
large: false,
premiumProgressBarEnabled: false,
applicationId: null,
afkTimeout: 300,
afkChannelId: null,
systemChannelId: null,
premiumTier: 1,
widgetEnabled: null,
widgetChannelId: null,
explicitContentFilter: 2,
mfaLevel: 1,
joinedTimestamp: 1690219661252,
defaultMessageNotifications: 1,
systemChannelFlags:
[AutoModerationRuleManager],
available: true,
shardId: 0,
splash: null,
banner: null,
description: null,
verificationLevel: 2,
vanityURLCode: null,
nsfwLevel: 0,
premiumSubscriptionCount: 2,
discoverySplash: null,
memberCount: 14,
large: false,
premiumProgressBarEnabled: false,
applicationId: null,
afkTimeout: 300,
afkChannelId: null,
systemChannelId: null,
premiumTier: 1,
widgetEnabled: null,
widgetChannelId: null,
explicitContentFilter: 2,
mfaLevel: 1,
joinedTimestamp: 1690219661252,
defaultMessageNotifications: 1,
systemChannelFlags:
[SystemChannelFlagsBitField],
maximumMembers: 500000,
maximumPresences: null,
maxVideoChannelUsers: 25,
maxStageVideoChannelUsers: 50,
approximateMemberCount: null,
approximatePresenceCount: null,
vanityURLUses: null,
rulesChannelId: '1130568875654787092',
publicUpdatesChannelId: '1132378959460438026',
preferredLocale: 'en-US',
safetyAlertsChannelId: null,
ownerId: '525790133937635378',
emojis: [GuildEmojiManager],
stickers: [GuildStickerManager]
},
joinedTimestamp: 1604917962340,
premiumSinceTimestamp: null,
nickname: null,
pending: false,
communicationDisabledUntilTimestamp: null,
_roles: [],
user: User {
id: '525790133937635378',
bot: false,
system: false,
flags: [UserFlagsBitField],
username: 'sakatanoraj',
discriminator: '0',
avatar: 'f3bd2ed87d413d837594ff455a105d59',
banner: undefined,
accentColor: undefined
},
avatar: null,
flags: GuildMemberFlagsBitField { bitfield: 0 }
},
version: 1,
appPermissions: PermissionsBitField { bitfield: 140737488355327n },
memberPermissions: PermissionsBitField { bitfield: 140737488355327n },
locale: 'fr',
guildLocale: 'en-US',
commandId: '1133088668962271363',
commandName: 'ping',
commandType: 1,
commandGuildId: '775306869978824714',
deferred: false,
replied: false,
ephemeral: null,
webhook: InteractionWebhook { id: '1132442679737864287' },
options: CommandInteractionOptionResolver {
_group: null,
_subcommand: null,
_hoistedOptions: []
}
}
No command matching ping was found.
[SystemChannelFlagsBitField],
maximumMembers: 500000,
maximumPresences: null,
maxVideoChannelUsers: 25,
maxStageVideoChannelUsers: 50,
approximateMemberCount: null,
approximatePresenceCount: null,
vanityURLUses: null,
rulesChannelId: '1130568875654787092',
publicUpdatesChannelId: '1132378959460438026',
preferredLocale: 'en-US',
safetyAlertsChannelId: null,
ownerId: '525790133937635378',
emojis: [GuildEmojiManager],
stickers: [GuildStickerManager]
},
joinedTimestamp: 1604917962340,
premiumSinceTimestamp: null,
nickname: null,
pending: false,
communicationDisabledUntilTimestamp: null,
_roles: [],
user: User {
id: '525790133937635378',
bot: false,
system: false,
flags: [UserFlagsBitField],
username: 'sakatanoraj',
discriminator: '0',
avatar: 'f3bd2ed87d413d837594ff455a105d59',
banner: undefined,
accentColor: undefined
},
avatar: null,
flags: GuildMemberFlagsBitField { bitfield: 0 }
},
version: 1,
appPermissions: PermissionsBitField { bitfield: 140737488355327n },
memberPermissions: PermissionsBitField { bitfield: 140737488355327n },
locale: 'fr',
guildLocale: 'en-US',
commandId: '1133088668962271363',
commandName: 'ping',
commandType: 1,
commandGuildId: '775306869978824714',
deferred: false,
replied: false,
ephemeral: null,
webhook: InteractionWebhook { id: '1132442679737864287' },
options: CommandInteractionOptionResolver {
_group: null,
_subcommand: null,
_hoistedOptions: []
}
}
No command matching ping was found.
sorry
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
s a k a  t a
s a k a t aOP17mo ago
s a k a  t a
s a k a t aOP17mo ago
thats the error in question so idk thats the only thing i see
Unknown User
Unknown User17mo ago
Message Not Public
Sign In & Join Server To View
s a k a  t a
s a k a t aOP16mo ago
sorry for the late response too
s a k a  t a
s a k a t aOP16mo ago
s a k a  t a
s a k a t aOP16mo ago
so that is the ping command can you please ping me when u gonna answer this question thanks u
treble/luna
treble/luna16mo ago
and do you listen to the interactionCreate event? If so show that code
s a k a  t a
s a k a t aOP16mo ago
didnt understand, what code do you want me to show u
treble/luna
treble/luna16mo ago
Your interactionCreate event
s a k a  t a
s a k a t aOP16mo ago
s a k a  t a
s a k a t aOP16mo ago
into that
s a k a  t a
s a k a t aOP16mo ago
like in the guide ig
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();

client.commands = new Collection();

client.login(token);

client.once(Events.ClientReady, c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
}
else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}

client.on(Events.InteractionCreate, interaction => {
if (!interaction.isChatInputCommand()) return;
console.log(interaction);
});
const fs = require('node:fs');
const path = require('node:path');
const { Client, Collection, Events, GatewayIntentBits } = require('discord.js');
const { token } = require('./config.json');

const client = new Client({ intents: [GatewayIntentBits.Guilds] });

client.commands = new Collection();

client.commands = new Collection();

client.login(token);

client.once(Events.ClientReady, c => {
console.log(`Ready! Logged in as ${c.user.tag}`);
});

const commandsPath = path.join(__dirname, 'commands');
const commandFiles = fs.readdirSync(commandsPath).filter(file => file.endsWith('.js'));

for (const file of commandFiles) {
const filePath = path.join(commandsPath, file);
const command = require(filePath);
// Set a new item in the Collection with the key as the command name and the value as the exported module
if ('data' in command && 'execute' in command) {
client.commands.set(command.data.name, command);
}
else {
console.log(`[WARNING] The command at ${filePath} is missing a required "data" or "execute" property.`);
}
}

client.on(Events.InteractionCreate, interaction => {
if (!interaction.isChatInputCommand()) return;
console.log(interaction);
});
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
}
catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
}
else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});
client.on(Events.InteractionCreate, async interaction => {
if (!interaction.isChatInputCommand()) return;

const command = interaction.client.commands.get(interaction.commandName);

if (!command) {
console.error(`No command matching ${interaction.commandName} was found.`);
return;
}

try {
await command.execute(interaction);
}
catch (error) {
console.error(error);
if (interaction.replied || interaction.deferred) {
await interaction.followUp({ content: 'There was an error while executing this command!', ephemeral: true });
}
else {
await interaction.reply({ content: 'There was an error while executing this command!', ephemeral: true });
}
}
});
mb for thhe first one idk, and idk ab the subfolders, one people said i have to put them in sub, then u say i dont have to idk anymore how can i do to put them in subfolders i think i just fuck my code at a point but idk when
treble/luna
treble/luna16mo ago
fix your folders or fix the way you scan your directories and import your files
s a k a  t a
s a k a t aOP16mo ago
do you know how can i fix that? just the way to scan my directories i already did that? i mean how can i scan my subfolder?
Want results from more Discord servers?
Add your server