Command dissapears

Hi there so I have this little issue with one of my new commands some useless background information. My bot is hosted on my linux server that I recently have moved it to from AWS to a cloud server everything was working perfect until I added a new command. So one day I added a new command to my command folder, I use ssh in VSCode to edit all my files, add new files etc. My new command has been added to the correct folder with all the other commands, usually I wouldn't need to rerun the deploy commands.js file in order to update the commands as I will just use
systemctl restart bot
systemctl restart bot
to update the commands as the index will run deploy-commands.js, but I noticed since I switched to the new cloud server it didn't show the new command, after clearing my discord cache (crtl+r/cmd+r), it still didn't work. so I'm confused why it doesn't work, I run deploy-commands.js manually and clear my cache again in order to hopefully view the command in the list, hmm it worked but after a few minutes I wanted to rerun the command and I get the error
Unkown integration
Unkown integration
, so I clear my discord cache again to check if it's still there and no it's not there anymore, I can do this over and over again but it keeps removing the command from the list, I am unsure what the possible problem could be. I will post the code as I don't think this is anything server related.
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const Timer = require('../../schemas/timer');

module.exports = {
data: new SlashCommandBuilder()
.setName('currentdrex')
.setDescription('Show your personal ongoing timer'),

async execute(interaction) {
const userId = interaction.user.id;
const guildId = interaction.guild.id;

const userTimer = await Timer.findOne({
userId: userId,
guildId: guildId,
type: "ongoing"
});

if (!userTimer) {
return interaction.reply({ content: "You don't have any active timers.", ephemeral: true });
}

const elapsedTime = new Date() - userTimer.startDate;

const hours = Math.floor(elapsedTime / (1000 * 60 * 60));
const minutes = Math.floor((elapsedTime % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((elapsedTime % (1000 * 60)) / 1000);

const embed = new EmbedBuilder()
.setTitle(`Your Current DREX Timer`)
.setDescription(`Elapsed time since ${new Date(userTimer.startDate).toLocaleString()}`)
.setColor('Green')
.addFields(
{ name: "Duration", value: `${hours}h ${minutes}m ${seconds}s`, inline: false }
);

await interaction.reply({ embeds: [embed] });
}
};
const { SlashCommandBuilder, EmbedBuilder } = require('discord.js');
const Timer = require('../../schemas/timer');

module.exports = {
data: new SlashCommandBuilder()
.setName('currentdrex')
.setDescription('Show your personal ongoing timer'),

async execute(interaction) {
const userId = interaction.user.id;
const guildId = interaction.guild.id;

const userTimer = await Timer.findOne({
userId: userId,
guildId: guildId,
type: "ongoing"
});

if (!userTimer) {
return interaction.reply({ content: "You don't have any active timers.", ephemeral: true });
}

const elapsedTime = new Date() - userTimer.startDate;

const hours = Math.floor(elapsedTime / (1000 * 60 * 60));
const minutes = Math.floor((elapsedTime % (1000 * 60 * 60)) / (1000 * 60));
const seconds = Math.floor((elapsedTime % (1000 * 60)) / 1000);

const embed = new EmbedBuilder()
.setTitle(`Your Current DREX Timer`)
.setDescription(`Elapsed time since ${new Date(userTimer.startDate).toLocaleString()}`)
.setColor('Green')
.addFields(
{ name: "Duration", value: `${hours}h ${minutes}m ${seconds}s`, inline: false }
);

await interaction.reply({ embeds: [embed] });
}
};
while running the deploy-commands.js it will also say the correct amount of commands so nothing wrong there, if you know anything more or suggestions for me please give me a ping so I get notified of any updates in the channel appreciate the time for reading this and possible answers ❤️
11 Replies
d.js toolkit
d.js toolkit4mo 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! - Marked as resolved by OP
NyR
NyR4mo ago
Show your deploy script. The above snippet is irrelevant (at least in this context)
Exenis
ExenisOP4mo ago
const { REST, Routes } = require("discord.js");
const { clientId, token } = require("./config.json");
const fs = require("node:fs");
const path = require("node:path");

const commands = [];
const foldersPath = path.join(__dirname, "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(".js"));
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.`
);

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

console.log(
`Successfully reloaded ${commands.length} application (/) commands.`
);
} catch (error) {
console.error(error);
}
})();
const { REST, Routes } = require("discord.js");
const { clientId, token } = require("./config.json");
const fs = require("node:fs");
const path = require("node:path");

const commands = [];
const foldersPath = path.join(__dirname, "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(".js"));
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.`
);

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

console.log(
`Successfully reloaded ${commands.length} application (/) commands.`
);
} catch (error) {
console.error(error);
}
})();
would seem odd to me if it was the deploy script as every time I have updated commands it worked fine
NyR
NyR4mo ago
And it logs the commands length correctly when you deploy?
Exenis
ExenisOP4mo ago
yes sir it does
NyR
NyR4mo ago
Instead of logging commands.length try logging the returned data.length from the PUT request. If it is still the same, then I suspect it is issue with discord client cache or something.
Exenis
ExenisOP4mo ago
deploy-commands gets manually ran, cache gets cleared and the command is there, few min later command stops working, I clear my cache again it's gone, very very odd
NyR
NyR4mo ago
Maybe you can check on a different device
Exenis
ExenisOP4mo ago
uhmm possibly actually database etc does work on the new server, turning the old server off rn have turned it off, will check in a minute
Exenis
ExenisOP4mo ago
Lightshot
Screenshot
Captured with Lightshot
Exenis
ExenisOP4mo ago
as of rn should stop working soon (unless it is because of the other server) yeah must've been the other server usually it should've been gone by now appreciate ya'll for the replies
Want results from more Discord servers?
Add your server