Azarak58
Azarak58
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
4638chocolaclap
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
thx you so much
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
oh yeah you were right its working now
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
Sweats
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
maybe i didnt put "guildtext" correctly
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
Fetching channel with ID 1146385311421710346
Error fetching or sending message: TypeError: Cannot read properties of undefined (reading 'GUILD_TEXT')
at updateUserXPInDatabase (C:\Users\Moham\OneDrive\Bureau\Project\Project Lina\models\updateXp.js:61:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Fetching channel with ID 1146385311421710346
Error fetching or sending message: TypeError: Cannot read properties of undefined (reading 'GUILD_TEXT')
at updateUserXPInDatabase (C:\Users\Moham\OneDrive\Bureau\Project\Project Lina\models\updateXp.js:61:62)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
try {
console.log(`Fetching channel with ID ${newRank.channelId}`);
const channel = await client.channels.fetch(newRank.channelId);
if (channel && channel.type === ChannelTypes.GUILD_TEXT) {
const congratsMessage = `Congratulations! You are now ${role.name} tier!`;
await channel.send(congratsMessage);
console.log(
`Congratulation message sent to channel ${channel.name}`
);
} else {
console.error(
`Channel with ID ${newRank.channelId} not found or not a text channel.`
);
}
} catch (error) {
console.error("Error fetching or sending message:", error);
}
try {
console.log(`Fetching channel with ID ${newRank.channelId}`);
const channel = await client.channels.fetch(newRank.channelId);
if (channel && channel.type === ChannelTypes.GUILD_TEXT) {
const congratsMessage = `Congratulations! You are now ${role.name} tier!`;
await channel.send(congratsMessage);
console.log(
`Congratulation message sent to channel ${channel.name}`
);
} else {
console.error(
`Channel with ID ${newRank.channelId} not found or not a text channel.`
);
}
} catch (error) {
console.error("Error fetching or sending message:", error);
}
like this ?
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
my terminal i have this
Fetching channel with ID 1146385311421710346
Channel with ID 1146385311421710346 not found or not a text channel.
Fetching channel with ID 1146385311421710346
Channel with ID 1146385311421710346 not found or not a text channel.
any idea where i messed up ?
25 replies
DIAdiscord.js - Imagine an app
Created by Azarak58 on 8/30/2023 in #djs-questions
Channel is not found ?
const Level = require("./level");

const rankInfo = [
{ range: [1, 9], rank: "1145704810138566708", xpRequired: 111, channelId: "1146385311421710346" }, // Common
{ range: [10, 29], rank: "1145704879520751687", xpRequired: 1111, channelId: "1146385311421710346" }, // Uncommon
{ range: [30, 49], rank: "1145704961699741748", xpRequired: 11111, channelId: "1146385311421710346" }, // Rare
{ range: [50, 69], rank: "1145705017886654534", xpRequired: 27777, channelId: "1146385311421710346" }, // Epic
{ range: [70, 89], rank: "1145705048882552982", xpRequired: 55555, channelId: "1146385334893019250" }, // Legendary
{ range: [90, 99], rank: "1145705091697999925", xpRequired: 111111, channelId: "1146385334893019250" }, // Mythical
{ range: [100, 100], rank: "1145705144579788860", xpRequired: 0, channelId: "1146385334893019250" }, // Divine
];

...

const updateUserXPInDatabase = async (userId, message, client) => {

...

try {
console.log(`Fetching channel with ID ${newRank.channelId}`);
const channel = await client.channels.fetch(newRank.channelId);
if (channel && channel.type === "text") {
const congratsMessage = `Congratulations! You are now ${role.name} tier!`;
await channel.send(congratsMessage);
console.log(
`Congratulation message sent to channel ${channel.name}`
);
} else {
console.error(
`Channel with ID ${newRank.channelId} not found or not a text channel.`
);
}
} catch (error) {
console.error("Error fetching or sending message:", error);
}
}
} else {
console.error(`Role with ID ${newRank.rank} not found.`);
}
}
}

...

module.exports = {
updateUserXPInDatabase,
};
const Level = require("./level");

const rankInfo = [
{ range: [1, 9], rank: "1145704810138566708", xpRequired: 111, channelId: "1146385311421710346" }, // Common
{ range: [10, 29], rank: "1145704879520751687", xpRequired: 1111, channelId: "1146385311421710346" }, // Uncommon
{ range: [30, 49], rank: "1145704961699741748", xpRequired: 11111, channelId: "1146385311421710346" }, // Rare
{ range: [50, 69], rank: "1145705017886654534", xpRequired: 27777, channelId: "1146385311421710346" }, // Epic
{ range: [70, 89], rank: "1145705048882552982", xpRequired: 55555, channelId: "1146385334893019250" }, // Legendary
{ range: [90, 99], rank: "1145705091697999925", xpRequired: 111111, channelId: "1146385334893019250" }, // Mythical
{ range: [100, 100], rank: "1145705144579788860", xpRequired: 0, channelId: "1146385334893019250" }, // Divine
];

...

const updateUserXPInDatabase = async (userId, message, client) => {

...

try {
console.log(`Fetching channel with ID ${newRank.channelId}`);
const channel = await client.channels.fetch(newRank.channelId);
if (channel && channel.type === "text") {
const congratsMessage = `Congratulations! You are now ${role.name} tier!`;
await channel.send(congratsMessage);
console.log(
`Congratulation message sent to channel ${channel.name}`
);
} else {
console.error(
`Channel with ID ${newRank.channelId} not found or not a text channel.`
);
}
} catch (error) {
console.error("Error fetching or sending message:", error);
}
}
} else {
console.error(`Role with ID ${newRank.rank} not found.`);
}
}
}

...

module.exports = {
updateUserXPInDatabase,
};
25 replies