error

not showing client online in console ??
36 Replies
d.js toolkit
d.js toolkit12mo 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
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
const client = require("../index");
const {
ActivityType
} = require('discord.js')

client.on("ready", () => {
console.log(`${client.user.tag} is online and ready to go!`);

client.user.setActivity(`${client.config.activity}`, {
type: ActivityType.Playing
});
client.user.setPresence({
status: 'online'
});
});
const client = require("../index");
const {
ActivityType
} = require('discord.js')

client.on("ready", () => {
console.log(`${client.user.tag} is online and ready to go!`);

client.user.setActivity(`${client.config.activity}`, {
type: ActivityType.Playing
});
client.user.setPresence({
status: 'online'
});
});
darp
darp12mo ago
You dont run client
client.login('MTA...');
client.login('MTA...');
Austn
AustnOP12mo ago
const {
Client,
GatewayIntentBits,
Collection,
} = require("discord.js");

const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a]
}),
});
module.exports = client;

// // Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.json");

// // Initializing the project
require("./handler")(client);



client.login(client.config.token);
const {
Client,
GatewayIntentBits,
Collection,
} = require("discord.js");

const client = new Client({
intents: Object.keys(GatewayIntentBits).map((a) => {
return GatewayIntentBits[a]
}),
});
module.exports = client;

// // Global Variables
client.commands = new Collection();
client.slashCommands = new Collection();
client.config = require("./config.json");

// // Initializing the project
require("./handler")(client);



client.login(client.config.token);
.
darp
darp12mo ago
Why not classes Or init function in module files
Austn
AustnOP12mo ago
in visual studio it runs but in vps it doesnt why
treble/luna
treble/luna12mo ago
First of all you do not need all intents Second if all i dont see you running node or any other command in that terminal
Austn
AustnOP12mo ago
i am using a web vps
treble/luna
treble/luna12mo ago
okay? what does that have to do with this
Shaun2177
Shaun217712mo ago
isn't 32767 just all intents?
d.js docs
d.js docs12mo ago
Tag suggestion for @Shaun2177: We highly recommend only specifying the intents you actually need. - Note, that 98303, 32767 or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
Shaun2177
Shaun217712mo ago
oh right, duh kekw
Austn
AustnOP12mo ago
const {
Client,
Collection
} = require("discord.js");

const client = new Client({
restTimeOffset: 0,
shards: "auto",
partials: ["MESSAGE", "CHANNEL", "REACTION", "GUILD_MEMBER", "USER"],
intents: 32767,
});
module.exports = client;

client.commands = new Collection();
client.slashCommands = new Collection();
client.developers = [
"",
""
]
require("./handler/index")(client);

client.config = require("./config.json")
client.login(client.config.token);
const {
Client,
Collection
} = require("discord.js");

const client = new Client({
restTimeOffset: 0,
shards: "auto",
partials: ["MESSAGE", "CHANNEL", "REACTION", "GUILD_MEMBER", "USER"],
intents: 32767,
});
module.exports = client;

client.commands = new Collection();
client.slashCommands = new Collection();
client.developers = [
"",
""
]
require("./handler/index")(client);

client.config = require("./config.json")
client.login(client.config.token);
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
until not running the code
d.js docs
d.js docs12mo ago
We highly recommend only specifying the intents you actually need. - Note, that 98303, 32767 or whatever other magic number you read that represents "all intents", gets outdated as soon as new intents are introduced. - The number will always represent the same set of intents, and will not include new ones. There is no magic "all intents" bit.
treble/luna
treble/luna12mo ago
those partials are not correct either i also only see you installing stuff but i dont see the command to actually start your index file anywhere
Austn
AustnOP12mo ago
it is in next file it is in another file before 2 3 days it runed properly with the same code but now its not running with the same code i tried in different vps also and it run locally in my computer but when i upload it in vps then it doesnt run it only comes on dosesnt show any response or any activity
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
no activity status only comming online
{
"dependencies": {
"discord.js": "^14.14.1",
"glob": "^10.3.10",
"pretty-ms": "^7.0.1"
}
}
{
"dependencies": {
"discord.js": "^14.14.1",
"glob": "^10.3.10",
"pretty-ms": "^7.0.1"
}
}
so i should install discord.js@13 or wot ?? le me check cmd command for checking discord.js version ? which file i should show ?? its 18.8.0 djs -v ?? its 14.13 ok
const {EmbedBuilder } = require("discord.js");
const {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Client,
Message,
ComponentType,
} = require("discord.js");
const { Link } = require("fs");

module.exports = {
name: "selfrole",
aliases: ["sr"],
description: "Self role here",
ownerOnly: true,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const selfroleEmbed = new EmbedBuilder()
.setAuthor({
name: "Reaction Roles"
})
.setDescription(`<@&1159855614156091444> - will be pinged for Server Announcements\n\n<@&1173470013420752946> - will be pinged for Vox Updates\n\n<@&1173469930650337382> - will be ping for any Vox Outgaes\n\n<@&1159855737112117310> - will be mentioned for Giveaway Drops`)
.setColor("#ff2b2b")
.setFooter({
text: "Managed By Vox Manager",
iconURL: `${client.user.displayAvatarURL()}`
});

const announcerole = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`📣`)
.setCustomId('announcerole');
const updatesrole = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`🔔`)
.setCustomId('updatesrole');
const botstatus = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`🟢`)
.setCustomId(`botstatus`)
;
const giveaway = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`🎁`)
.setCustomId(`giveaway`);


message.channel.send({ embeds: [selfroleEmbed], components : [new ActionRowBuilder().addComponents(announcerole,updatesrole,botstatus,giveaway)] });





},

};
const {EmbedBuilder } = require("discord.js");
const {
ActionRowBuilder,
ButtonBuilder,
ButtonStyle,
Client,
Message,
ComponentType,
} = require("discord.js");
const { Link } = require("fs");

module.exports = {
name: "selfrole",
aliases: ["sr"],
description: "Self role here",
ownerOnly: true,
/**
* @param {Client} client
* @param {Message} message
* @param {String[]} args
*/
run: async (client, message, args) => {
const selfroleEmbed = new EmbedBuilder()
.setAuthor({
name: "Reaction Roles"
})
.setDescription(`<@&1159855614156091444> - will be pinged for Server Announcements\n\n<@&1173470013420752946> - will be pinged for Vox Updates\n\n<@&1173469930650337382> - will be ping for any Vox Outgaes\n\n<@&1159855737112117310> - will be mentioned for Giveaway Drops`)
.setColor("#ff2b2b")
.setFooter({
text: "Managed By Vox Manager",
iconURL: `${client.user.displayAvatarURL()}`
});

const announcerole = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`📣`)
.setCustomId('announcerole');
const updatesrole = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`🔔`)
.setCustomId('updatesrole');
const botstatus = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`🟢`)
.setCustomId(`botstatus`)
;
const giveaway = new ButtonBuilder()
.setStyle(ButtonStyle.Secondary)
.setEmoji(`🎁`)
.setCustomId(`giveaway`);


message.channel.send({ embeds: [selfroleEmbed], components : [new ActionRowBuilder().addComponents(announcerole,updatesrole,botstatus,giveaway)] });





},

};
in ready.js file node . ?? no in vps i run it by the button given there it runs i think the index file ( the main file f the bot) yes it runs the index.js yes yes you got it support server of that vps
d.js docs
d.js docs12mo ago
Please add the following code to your code base outside of any other event listeners and provide the full log output relevant to your issue.
client
.on("debug", console.log)
.on("warn", console.log)
client
.on("debug", console.log)
.on("warn", console.log)
- Note: if you initialize your Client as bot or other identifiers you need to use these instead of client - If the output is too long to post consider using a bin instead: gist | paste.gg | sourceb.in | hastebin
Austn
AustnOP12mo ago
ok
npm ERR! A complete log of this run can be found in: /home/container/.npm/_logs/2023-12-08T18_19_29_683Z-debug-0.log
node:internal/modules/cjs/loader:1137
throw err;
^
Error: Cannot find module 'discord.js'
Require stack:
- /home/container/vox/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at Module._load (node:internal/modules/cjs/loader:975:27)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/home/container/vox/index.js:4:5)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/container/vox/index.js' ]
}
npm ERR! A complete log of this run can be found in: /home/container/.npm/_logs/2023-12-08T18_19_29_683Z-debug-0.log
node:internal/modules/cjs/loader:1137
throw err;
^
Error: Cannot find module 'discord.js'
Require stack:
- /home/container/vox/index.js
at Module._resolveFilename (node:internal/modules/cjs/loader:1134:15)
at Module._load (node:internal/modules/cjs/loader:975:27)
at Module.require (node:internal/modules/cjs/loader:1225:19)
at require (node:internal/modules/helpers:177:18)
at Object.<anonymous> (/home/container/vox/index.js:4:5)
at Module._compile (node:internal/modules/cjs/loader:1356:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1414:10)
at Module.load (node:internal/modules/cjs/loader:1197:32)
at Module._load (node:internal/modules/cjs/loader:1013:12)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:128:12) {
code: 'MODULE_NOT_FOUND',
requireStack: [ '/home/container/vox/index.js' ]
}
showing discord.js not found mmLol
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
@Qjuh
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 959
[WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
[WS => Shard 0] Waiting for event hello for 60000ms
[WS => Shard 0] Preparing first heartbeat of the connection with a jitter of 0.6434449746378454; waiting 26542ms
[WS => Shard 0] Waiting for identify throttle
[WS => Shard 0] Identifying
shard id: 0
shard count: 1
intents: 32767
compression: none
[WS => Shard 0] Waiting for event ready for 15000ms
[WS => Shard 0] Shard received all its guilds. Marking as fully ready.
[WS => Manager] Fetched Gateway Information
URL: wss://gateway.discord.gg
Recommended Shards: 1
[WS => Manager] Session Limit Information
Total: 1000
Remaining: 959
[WS => Shard 0] Connecting to wss://gateway.discord.gg?v=10&encoding=json
[WS => Shard 0] Waiting for event hello for 60000ms
[WS => Shard 0] Preparing first heartbeat of the connection with a jitter of 0.6434449746378454; waiting 26542ms
[WS => Shard 0] Waiting for identify throttle
[WS => Shard 0] Identifying
shard id: 0
shard count: 1
intents: 32767
compression: none
[WS => Shard 0] Waiting for event ready for 15000ms
[WS => Shard 0] Shard received all its guilds. Marking as fully ready.
[WS => Shard 0] First heartbeat sent, starting to beat every 41250ms
[WS => Shard 0] Heartbeat acknowledged, latency of 188ms.
[WS => Shard 0] First heartbeat sent, starting to beat every 41250ms
[WS => Shard 0] Heartbeat acknowledged, latency of 188ms.
tag me if u replied no its not wait i'll show you
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
its the bot
const client = require("../index");
const {
ActivityType
} = require('discord.js')

client.on("ready", () => {
console.log(`${client.user.tag} is online and ready to go!`);

client.user.setActivity(`Vox Supporters`, {
type: ActivityType.Listening
});
client.user.setPresence({
status: 'online'
});
});
const client = require("../index");
const {
ActivityType
} = require('discord.js')

client.on("ready", () => {
console.log(`${client.user.tag} is online and ready to go!`);

client.user.setActivity(`Vox Supporters`, {
type: ActivityType.Listening
});
client.user.setPresence({
status: 'online'
});
});
and this is the code ok w8
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
ok so now its logged in but why isnt it replying can you tell me ?/
d.js docs
d.js docs12mo ago
If you aren't getting any errors, try to place console.log checkpoints throughout your code to find out where execution stops. - Once you do, log relevant values and if-conditions - More sophisticated debugging methods are breakpoints and runtime inspections: learn more
Austn
AustnOP12mo ago
ok so i kept console.log(MessageContent) so it doesnt shows teh message it means message is not taken yeah
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
new error that has been solved
node:events:495
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\@discordjs\rest\dist\index.js:826:23)
at async _REST.request (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async ButtonInteraction.deferReply (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:69:5)
at async Client.<anonymous> (E:\felix_47\tropical-development\bots\tropical-manager\events\ticket.js:22:3)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:398:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: { files: undefined, json: { type: 5, data: { flags: 64 } } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1183343183338418247/aW50ZXJhY3Rpb246MTE4MzM0MzE4MzMzODQxODI0NzpMT01oYVBZNEZFYTdSRlBFNnM0TVE2TlBPdUdIbTNadlJKbDdkdUhoVFhXMDlhU2ppbjN6eDl3R2F1MFgzSzV6OFR1cGFJa0I5SkI4N2x5SnFTVDNzT0Y1dmZrazZRUkUzMU1idkNUbzNlTU13Q0cxbDUyZWExUGw1REhiRk9ycw/callback'
}
node:events:495
throw er; // Unhandled 'error' event
^

DiscordAPIError[10062]: Unknown interaction
at handleErrors (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\@discordjs\rest\dist\index.js:722:13)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async BurstHandler.runRequest (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\@discordjs\rest\dist\index.js:826:23)
at async _REST.request (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\@discordjs\rest\dist\index.js:1266:22)
at async ButtonInteraction.deferReply (E:\felix_47\tropical-development\bots\tropical-manager\node_modules\discord.js\src\structures\interfaces\InteractionResponses.js:69:5)
at async Client.<anonymous> (E:\felix_47\tropical-development\bots\tropical-manager\events\ticket.js:22:3)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:398:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
requestBody: { files: undefined, json: { type: 5, data: { flags: 64 } } },
rawError: { message: 'Unknown interaction', code: 10062 },
code: 10062,
status: 404,
method: 'POST',
url: 'https://discord.com/api/v10/interactions/1183343183338418247/aW50ZXJhY3Rpb246MTE4MzM0MzE4MzMzODQxODI0NzpMT01oYVBZNEZFYTdSRlBFNnM0TVE2TlBPdUdIbTNadlJKbDdkdUhoVFhXMDlhU2ppbjN6eDl3R2F1MFgzSzV6OFR1cGFJa0I5SkI4N2x5SnFTVDNzT0Y1dmZrazZRUkUzMU1idkNUbzNlTU13Q0cxbDUyZWExUGw1REhiRk9ycw/callback'
}
const botstatus = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1173469930650337382");
`18.` await btn.deferReply({
ephemeral: true
});

switch (btn.customId) {
case `${prefix}announcerole`:
{
const hasRole = await btn.member.roles.cache.has(announcerole?.id);
if (hasRole) {
await btn.member.roles.remove(announcerole);
await btn.editReply({
content: `Successfully removed ${announcerole} from your roles.`,
});
} else {
await btn.member.roles.add(announcerole);
await btn.editReply({
content: `Successfully added ${announcerole} from your roles.`,
});
}
}
const botstatus = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1173469930650337382");
`18.` await btn.deferReply({
ephemeral: true
});

switch (btn.customId) {
case `${prefix}announcerole`:
{
const hasRole = await btn.member.roles.cache.has(announcerole?.id);
if (hasRole) {
await btn.member.roles.remove(announcerole);
await btn.editReply({
content: `Successfully removed ${announcerole} from your roles.`,
});
} else {
await btn.member.roles.add(announcerole);
await btn.editReply({
content: `Successfully added ${announcerole} from your roles.`,
});
}
}
its the 18th line
const type = String(interaction.customId).split("_")[1];
22. await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});

const buttons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setEmoji(config.emojis.close)
.setLabel("Close Ticket")
.setCustomId("ticket_close")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setEmoji(config.emojis.transcipt)
.setLabel("Transcript")
.setCustomId("ticket_transcript")
.setStyle(ButtonStyle.Secondary)
);
const type = String(interaction.customId).split("_")[1];
22. await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});

const buttons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setEmoji(config.emojis.close)
.setLabel("Close Ticket")
.setCustomId("ticket_close")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setEmoji(config.emojis.transcipt)
.setLabel("Transcript")
.setCustomId("ticket_transcript")
.setStyle(ButtonStyle.Secondary)
);
no this is the file where it says error but when i do the interaction of that file i provided first thee occurs no oh yeah like that folder i provided first has a button so when i press that button it shows this error and which leads saying ticket.js/22 idk whats happening
const type = String(interaction.customId).split("_")[1];
await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});
const type = String(interaction.customId).split("_")[1];
await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});
ticket.js
const announcerole = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1159855614156091444");
const updatesrole = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1173470013420752946");
const botstatus = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1173469930650337382");
await btn.deferReply({
ephemeral: true
});
const announcerole = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1159855614156091444");
const updatesrole = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1173470013420752946");
const botstatus = client.guilds.cache
.get(btn.guildId)
.roles.cache.get("1173469930650337382");
await btn.deferReply({
ephemeral: true
});
selfrole.js it has have have kept same interaction id in both got it @Qjuh
client.on("clickCreate", async (click) => {
if (
!click.isButton() &&
String(interaction.customId).startsWith("ticket_")
)
return;

const type = String(interaction.customId).split("_")[1];
await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});
client.on("clickCreate", async (click) => {
if (
!click.isButton() &&
String(interaction.customId).startsWith("ticket_")
)
return;

const type = String(interaction.customId).split("_")[1];
await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});
why its not working ok yes i undersrtand i have two events by same name' so its not working ok
String(interaction.customId).startsWith("ticket_")
)
return;

const type = String(interaction.customId).split("_")[1];
await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});

const buttons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setEmoji(config.emojis.close)
.setLabel("Close Ticket")
.setCustomId("ticket_close")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setEmoji(config.emojis.transcipt)
.setLabel("Transcript")
.setCustomId("ticket_transcript")
.setStyle(ButtonStyle.Secondary)
);
String(interaction.customId).startsWith("ticket_")
)
return;

const type = String(interaction.customId).split("_")[1];
await interaction.deferReply({
ephemeral: ["transcript"].includes(type) ? false : true,
});

const buttons = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setEmoji(config.emojis.close)
.setLabel("Close Ticket")
.setCustomId("ticket_close")
.setStyle(ButtonStyle.Secondary),
new ButtonBuilder()
.setEmoji(config.emojis.transcipt)
.setLabel("Transcript")
.setCustomId("ticket_transcript")
.setStyle(ButtonStyle.Secondary)
);
i thinks its filtered by ticket_
treble/luna
treble/luna12mo ago
also, .customId is a string so no need to string it again
Austn
AustnOP12mo ago
No description
Austn
AustnOP12mo ago
what to do to disable actionrowmenu after a certain time ?? selectMenuRow. ???
Want results from more Discord servers?
Add your server