NP
NP
DIdiscord.js - Imagine ❄
Created by NP on 1/18/2025 in #djs-questions
ERROR: Shard 29's Client took too long to become ready
I have a bot where it comes up with this error randomly and causes the bot to crash, I then need to restart the server. any ideas how to resolve? here's the sharding code:
import dotenv from 'dotenv';
import { ShardingManager } from 'discord.js';

dotenv.config();
const manager = new ShardingManager('./src/bot.js', {
token: process.env.DISCORD_BOT_TOKEN,
respawn: true, // Automatically respawn shards if they fail
timeout: 120_000 // Increase timeout to 120 seconds
});

manager.on('shardCreate', shard => {
console.log(`Launched shard ${shard.id}`);
});

manager.spawn({ delay: 5000 }) // Adds a 5-second delay between shards
.then(() => console.log('All shards launched successfully.'))
.catch(error => console.error('Error while spawning shards:', error));
import dotenv from 'dotenv';
import { ShardingManager } from 'discord.js';

dotenv.config();
const manager = new ShardingManager('./src/bot.js', {
token: process.env.DISCORD_BOT_TOKEN,
respawn: true, // Automatically respawn shards if they fail
timeout: 120_000 // Increase timeout to 120 seconds
});

manager.on('shardCreate', shard => {
console.log(`Launched shard ${shard.id}`);
});

manager.spawn({ delay: 5000 }) // Adds a 5-second delay between shards
.then(() => console.log('All shards launched successfully.'))
.catch(error => console.error('Error while spawning shards:', error));
6 replies
DIdiscord.js - Imagine ❄
Created by NP on 1/11/2025 in #djs-questions
unknown interaction error
hey, i get the below error. I have tried to add an acknowledgement to the interaction, as we get the response from the API, so could take a while, but it still errors. It's intermittent.
await command.execute(interaction);
} catch (error) {
console.error(error);
// Handle errors only if the interaction hasn't been replied or deferred
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.InviteDelete, async invite => {
if(!botEnabled()) return;
const guildId = invite.guild.id;
await command.execute(interaction);
} catch (error) {
console.error(error);
// Handle errors only if the interaction hasn't been replied or deferred
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.InviteDelete, async invite => {
if(!botEnabled()) return;
const guildId = invite.guild.id;
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:826:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1266:22)
at async ChatInputCommandInteraction.deferReply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:69:5)
at async Object.execute (file:///app/src/commands.js:45:5)
at async Client.<anonymous> (file:///app/src/bot.js:62:3) {
requestBody: { files: undefined, json: { type: 5, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1327467424752341022/aW50ZXJhY3Rpb246MTMyNzQ2NzQyNDc1MjM0MTAyMjo3OTdrdXl0RlhESWZjaFM4d01XRm5keGNaNUFwR3FFY0RRbVp6TG1hemt6Tm8wejdtYW1CSWxqUWZHTDJUT2RTdzlSWEU0bHZHQ0g1aHY2cDJjVmJSczRhU3BCMDNncU03akFESzVnczJNNDNWQTl0ZDZsaHBTWkJOb29yOTZ0bQ/callback'
}
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:826:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1266:22)
at async ChatInputCommandInteraction.reply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
at async Client.<anonymous> (file:///app/src/bot.js:69:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1327467424752341022/aW50ZXJhY3Rpb246MTMyNzQ2NzQyNDc1MjM0MTAyMjo3OTdrdXl0RlhESWZjaFM4d01XRm5keGNaNUFwR3FFY0RRbVp6TG1hemt6Tm8wejdtYW1CSWxqUWZHTDJUT2RTdzlSWEU0bHZHQ0g1aHY2cDJjVmJSczRhU3BCMDNncU03akFESzVnczJNNDNWQTl0ZDZsaHBTWkJOb29yOTZ0bQ/callback'
}
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:826:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1266:22)
at async ChatInputCommandInteraction.deferReply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:69:5)
at async Object.execute (file:///app/src/commands.js:45:5)
at async Client.<anonymous> (file:///app/src/bot.js:62:3) {
requestBody: { files: undefined, json: { type: 5, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1327467424752341022/aW50ZXJhY3Rpb246MTMyNzQ2NzQyNDc1MjM0MTAyMjo3OTdrdXl0RlhESWZjaFM4d01XRm5keGNaNUFwR3FFY0RRbVp6TG1hemt6Tm8wejdtYW1CSWxqUWZHTDJUT2RTdzlSWEU0bHZHQ0g1aHY2cDJjVmJSczRhU3BCMDNncU03akFESzVnczJNNDNWQTl0ZDZsaHBTWkJOb29yOTZ0bQ/callback'
}
DiscordAPIError[10062]: Unknown interaction
at handleErrors (/app/node_modules/@discordjs/rest/dist/index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (/app/node_modules/@discordjs/rest/dist/index.js:826:23)
at async _REST.request (/app/node_modules/@discordjs/rest/dist/index.js:1266:22)
at async ChatInputCommandInteraction.reply (/app/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:111:5)
at async Client.<anonymous> (file:///app/src/bot.js:69:4) {
requestBody: { files: [], json: { type: 4, data: [Object] } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1327467424752341022/aW50ZXJhY3Rpb246MTMyNzQ2NzQyNDc1MjM0MTAyMjo3OTdrdXl0RlhESWZjaFM4d01XRm5keGNaNUFwR3FFY0RRbVp6TG1hemt6Tm8wejdtYW1CSWxqUWZHTDJUT2RTdzlSWEU0bHZHQ0g1aHY2cDJjVmJSczRhU3BCMDNncU03akFESzVnczJNNDNWQTl0ZDZsaHBTWkJOb29yOTZ0bQ/callback'
}
32 replies
DIdiscord.js - Imagine ❄
Created by NP on 1/5/2025 in #djs-questions
Shards and presence
Hey, I’m looking to get a rotating presence on a discord bot. The bot auto brings up around 38 shards, and so the prescience is a little bit messed up when it changes. I’ve set it to one minute to change, but as all shards start at different times that’s ruined. Not sure what the correct way to do this is?
5 replies
DIdiscord.js - Imagine ❄
Created by NP on 8/6/2023 in #djs-questions
application did not reply
Hi, I seem to be getting this error about the application not replying, but it replys in a seperate message. https://media.discordapp.net/attachments/1090613260195217519/1137334679020781618/image.png?width=223&height=129
4 replies
DIdiscord.js - Imagine ❄
Created by NP on 5/6/2023 in #djs-questions
Time not processing
Hi, can someone help me with a bug in the code? If I put 2m or 2d or 2w the bot takes all of them as 2s.
13 replies
DIdiscord.js - Imagine ❄
Created by NP on 5/2/2023 in #djs-questions
file being sent with content object object
Hi, the transcript file from here is being sent to GitHub with the contents of the file as [object Object] GitHub Integration:
import { Octokit } from "@octokit/rest";
import fs from "fs";

const octokit = new Octokit({ auth: "go3df8KI2dcd89" });

const owner = "repo";
const repo = "transcripts";
const branch = "main";

const createFileInRepo = async (
filePath: string,
content: string,
commitMessage: string,
) => {
try {
// Get the SHA of the latest commit
const { data: refData } = await octokit.git.getRef({
owner,
repo,
ref: `heads/${branch}`,
});
const sha = refData.object.sha;

// Get the latest commit
const { data: commitData } = await octokit.git.getCommit({
owner,
repo,
commit_sha: sha,
});

// Create a new tree with the new file
const { data: treeData } = await octokit.git.createTree({
owner,
repo,
base_tree: commitData.tree.sha,
tree: [
{
path: filePath,
mode: "100644",
content: content,
},
],
});

// Create a new commit with the new tree
const { data: commit } = await octokit.git.createCommit({
owner,
repo,
message: commitMessage,
tree: treeData.sha,
parents: [sha],
});

// Update the branch reference to point to the new commit
await octokit.git.updateRef({
owner,
repo,
ref: `heads/${branch}`,
sha: commit.sha,
});

console.log(`File ${filePath} created in repository ${owner}/${repo}`);
} catch (error) {
console.error(`Error creating file in repository: ${error}`);
}
};

export default createFileInRepo;
import { Octokit } from "@octokit/rest";
import fs from "fs";

const octokit = new Octokit({ auth: "go3df8KI2dcd89" });

const owner = "repo";
const repo = "transcripts";
const branch = "main";

const createFileInRepo = async (
filePath: string,
content: string,
commitMessage: string,
) => {
try {
// Get the SHA of the latest commit
const { data: refData } = await octokit.git.getRef({
owner,
repo,
ref: `heads/${branch}`,
});
const sha = refData.object.sha;

// Get the latest commit
const { data: commitData } = await octokit.git.getCommit({
owner,
repo,
commit_sha: sha,
});

// Create a new tree with the new file
const { data: treeData } = await octokit.git.createTree({
owner,
repo,
base_tree: commitData.tree.sha,
tree: [
{
path: filePath,
mode: "100644",
content: content,
},
],
});

// Create a new commit with the new tree
const { data: commit } = await octokit.git.createCommit({
owner,
repo,
message: commitMessage,
tree: treeData.sha,
parents: [sha],
});

// Update the branch reference to point to the new commit
await octokit.git.updateRef({
owner,
repo,
ref: `heads/${branch}`,
sha: commit.sha,
});

console.log(`File ${filePath} created in repository ${owner}/${repo}`);
} catch (error) {
console.error(`Error creating file in repository: ${error}`);
}
};

export default createFileInRepo;
11 replies
DIdiscord.js - Imagine ❄
Created by NP on 5/1/2023 in #djs-questions
Attachment sending in wrong channel.
Hi, the attachment is sending in the interaction channel and not logging channel. Anyone know why?
14 replies
DIdiscord.js - Imagine ❄
Created by NP on 5/1/2023 in #djs-questions
Help with file/send
Hi, I require some help as this code doesn't work.
10 replies
DIdiscord.js - Imagine ❄
Created by NP on 10/29/2022 in #djs-questions
How do I fix this issue?
26 replies
DIdiscord.js - Imagine ❄
Created by NP on 10/5/2022 in #djs-questions
modal error
46 replies
DIdiscord.js - Imagine ❄
Created by NP on 9/25/2022 in #djs-questions
Error when launching bot
3 replies
DIdiscord.js - Imagine ❄
Created by NP on 9/25/2022 in #djs-questions
Merging two bots together
I am a beginner developer and I am currently using github bots to help me learn to code. I have 2 bots which work great individually, but I would like them in the same bot - Can someone please help me to do this?
3 replies
DIdiscord.js - Imagine ❄
Created by NP on 9/25/2022 in #djs-questions
Add custom emoji to button
13 replies
DIdiscord.js - Imagine ❄
Created by NP on 9/22/2022 in #djs-questions
Error when sending bot to host
5 replies