i'm using slash commands and it do not work for me on a my server, but on another server it work wit

-
47 Replies
d.js toolkit
d.js toolkit•16mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button!
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
[email protected] there's no errors + It just doesn't work on my server
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
const rest = new REST({version: '10'}).setToken(TOKEN);

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

await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: commands,
});

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
const rest = new REST({version: '10'}).setToken(TOKEN);

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

await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: commands,
});

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();
wdym
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
yes i told u it works for me on another server i change the guildId
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
idk but i change the guildId and it doesnt work how can i know
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
yeah i didnt see them
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
how can i register the commands 😃
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
yeah i run it
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
i know bro i do it
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
the same code this is not the full code
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
ofc i'm running the full code in index.js
const { Client, EmbedBuilder, REST, Routes, SlashCommandBuilder, GatewayIntentBits, ChannelType, Partials } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Channel],
});

const TOKEN = '';
const guildId = '1133106934132768768';
const clientId = '1101538230026915890';


client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});

const commands = [
new SlashCommandBuilder()
.setName('zajil')
.setDescription('Send a message as unknown or known')
.addUserOption(option =>
option.setName('user').setDescription('The user to mention').setRequired(true)
)
.addStringOption(option =>
option
.setName('message')
.setDescription('The message to send')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('status')
.setDescription('Choose unknown or known')
.setRequired(true)
.addChoices(
{ name: 'unknown', value: 'unknown'},
{ name:'known', value: 'known'}
)
)
.toJSON(),
];

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

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

await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: commands,
});

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();




//////////////////////////////////////////////////////////////////////

client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand() || interaction.commandName !== 'zajil') return;

const user = interaction.options.getUser('user');
const message = interaction.options.getString('message');
const status = interaction.options.getString('status');

let from;
if (status === 'known') {
from = `زاجل من :${interaction.user.username}`
} else if (status === 'unknown') {
from = `زاجل من مجهول`
} else {
return interaction.reply({ content: 'اختر اما ان تكون مجهول ام غير مجهول', ephemeral: true });
}

const embed = new EmbedBuilder()
.setDescription(`**${message}**`)
.setAuthor({ name: from})
.setFooter({ text: 'elve server', iconURL: interaction.guild.iconURL() })
.setThumbnail(user.displayAvatarURL())
.setColor('#267d87')

try {
const channel = client.channels.cache.get('1135233204350107731');

await interaction.reply({
content: `> **تم ارسال الزاجل بنجاح , <#${channel.id}>**`,
ephemeral: true,
});

if (channel.type === ChannelType.GuildText) {
await channel.send({content: `> **${user} وصل لك زاجل**`, embeds: [embed] });
}
} catch (error) {
console.error('Error while handling /zajil command:', error);
}
});


client.on('messageCreate', async (message) => {
if (message.channel.id === '1135230590183030915' && !message.author.bot) {
try {
await message.delete();
} catch (error) {
console.error('Error while deleting message:', error);
}
}
});


client.login(TOKEN)
const { Client, EmbedBuilder, REST, Routes, SlashCommandBuilder, GatewayIntentBits, ChannelType, Partials } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.GuildMembers,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
],
partials: [Partials.Channel],
});

const TOKEN = '';
const guildId = '1133106934132768768';
const clientId = '1101538230026915890';


client.on('ready', () => {
console.log(`Logged in as ${client.user.tag}!`);
});

const commands = [
new SlashCommandBuilder()
.setName('zajil')
.setDescription('Send a message as unknown or known')
.addUserOption(option =>
option.setName('user').setDescription('The user to mention').setRequired(true)
)
.addStringOption(option =>
option
.setName('message')
.setDescription('The message to send')
.setRequired(true)
)
.addStringOption(option =>
option
.setName('status')
.setDescription('Choose unknown or known')
.setRequired(true)
.addChoices(
{ name: 'unknown', value: 'unknown'},
{ name:'known', value: 'known'}
)
)
.toJSON(),
];

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

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

await rest.put(Routes.applicationGuildCommands(clientId, guildId), {
body: commands,
});

console.log('Successfully reloaded application (/) commands.');
} catch (error) {
console.error(error);
}
})();




//////////////////////////////////////////////////////////////////////

client.on('interactionCreate', async (interaction) => {
if (!interaction.isCommand() || interaction.commandName !== 'zajil') return;

const user = interaction.options.getUser('user');
const message = interaction.options.getString('message');
const status = interaction.options.getString('status');

let from;
if (status === 'known') {
from = `زاجل من :${interaction.user.username}`
} else if (status === 'unknown') {
from = `زاجل من مجهول`
} else {
return interaction.reply({ content: 'اختر اما ان تكون مجهول ام غير مجهول', ephemeral: true });
}

const embed = new EmbedBuilder()
.setDescription(`**${message}**`)
.setAuthor({ name: from})
.setFooter({ text: 'elve server', iconURL: interaction.guild.iconURL() })
.setThumbnail(user.displayAvatarURL())
.setColor('#267d87')

try {
const channel = client.channels.cache.get('1135233204350107731');

await interaction.reply({
content: `> **تم ارسال الزاجل بنجاح , <#${channel.id}>**`,
ephemeral: true,
});

if (channel.type === ChannelType.GuildText) {
await channel.send({content: `> **${user} وصل لك زاجل**`, embeds: [embed] });
}
} catch (error) {
console.error('Error while handling /zajil command:', error);
}
});


client.on('messageCreate', async (message) => {
if (message.channel.id === '1135230590183030915' && !message.author.bot) {
try {
await message.delete();
} catch (error) {
console.error('Error while deleting message:', error);
}
}
});


client.login(TOKEN)
2 hours ago it was working fine
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
yep wait
.Mn
.MnOP•16mo ago
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
no do u think if i have system bot may it delete the bot from integrations?
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
idk when i delete the integration for the bot
.Mn
.MnOP•16mo ago
if i delete i can't get it back?
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
i give him ban and kick and invite it again 50 times 🥲
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
ok wait a seconds requestBody: { files: undefined, json: [ [Object] ] }, rawError: { message: 'Missing Access', code: 50001 }, code: 50001, status: 403, method: 'PUT', url: 'https://discord.com/api/v10/applications/1101538230026915890/guilds/1133106934132768768/commands' }
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
now can i invite it?
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
ok
.Mn
.MnOP•16mo ago
this permissions right?
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
yep
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
DIDNT WORK BUT ILL FIX IT
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
I HAVE SYSTEM BOT
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
.Mn
.MnOP•16mo ago
SRY sry ok i have system bot when bots join with permissions it delete the perms i think thats the reason idk
Unknown User
Unknown User•16mo ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server