TypeError: Cannot read properties of undefined (reading 'id')
21.02 21:48:58 [Bot] at Object.module.exports.run (/commands/levels.js:10:35)
21.02 21:48:58 [Bot] at Client.<anonymous> (/index.js:78:31)
21.02 21:48:58 [Bot] at Client.emit (node:events:390:28)
21.02 21:48:58 [Bot] at MessageCreateAction.handle (/node_modules/discord.js/src/client/actions/MessageCreate.js:26:14)
21.02 21:48:58 [Bot] at Object.module.exports [as MESSAGE_CREATE] (/node_modules/discord.js/src/client/websocket/handlers/MESSAGE_CREATE.js:4:32)
21.02 21:48:58 [Bot] at WebSocketManager.handlePacket (/node_modules/discord.js/src/client/websocket/WebSocketManager.js:351:31)
21.02 21:48:58 [Bot] at WebSocketShard.onPacket (/node_modules/discord.js/src/client/websocket/WebSocketShard.js:444:22)
21.02 21:48:58 [Bot] at WebSocketShard.onMessage (/node_modules/discord.js/src/client/websocket/WebSocketShard.js:301:10)
21.02 21:48:58 [Bot] at WebSocket.onMessage (/node_modules/ws/lib/event-target.js:199:18)
21.02 21:48:58 [Bot] at WebSocket.emit (node:events:390:28)
#error levels
1 messages · Page 1 of 1 (latest)
const discord = require("discord.js");
const fs = require("fs");
const canvacord = require("canvacord");
const { MessageAttachment } = require("discord.js");
module.exports.run = async (client, message, interaction, args) => {
var levelFile = JSON.parse(fs.readFileSync("./Data/levels.json"));
var userID = interaction.user.id;
try{
var nextLevelXP = levelFile[userID].level * 300;
if (nextLevelXP == 0) nextLevelXP == 100;
const rank = new canvacord.Rank()
.setAvatar(interaction.displayAvatarURL({dynamic: false, format: "png"}))
.setCurrentXP(levelFile[userID].xp)
.setLevel(levelFile[userID].level)
.setRequiredXP(nextLevelXP)
.setProgressBar("#FFA500", "COLOR")
.setUsername(interaction.user.username)
.setDiscriminator(interaction.user.discriminator);
rank.build().then (data => {
const attachment = new MessageAttachment(data, "RankCard.png");
interaction.reply({ files: [attachment] });
})
}catch(err) {
interaction.reply({ content: "❌ No data found!" });
}
}
module.exports.help = {
name: "level"
}
are you sure you are calling the function with client, message, interaction, args
how can i fix it
how do you call it?
meaning which arguments do you pass?
if you can't answer this question you should brush up on your js knowledge in #resources
ehh i have made it for /commands but i want to make it for prefix commands
interaction
meaning which arguments do you pass?