can send normal message but cant send embded message

try {
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
console.log(`Successfully sent LeetCode question to ${member.user.tag}`);
const redirectChannel = member.guild.channels.cache.get(
config.LEETCODE_LOGS_CHANNEL_ID,
);
await redirectChannel.send(
`Successfully sent LeetCode question to ${member.user.tag}`,
);
} catch (error) {
console.error(`Failed to send DM to ${member.user.tag}:`, error);
}
try {
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
console.log(`Successfully sent LeetCode question to ${member.user.tag}`);
const redirectChannel = member.guild.channels.cache.get(
config.LEETCODE_LOGS_CHANNEL_ID,
);
await redirectChannel.send(
`Successfully sent LeetCode question to ${member.user.tag}`,
);
} catch (error) {
console.error(`Failed to send DM to ${member.user.tag}:`, error);
}
this code works
14 Replies
d.js toolkit
d.js toolkit2mo 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
Auth
AuthOP2mo ago
but
try {
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
console.log(`Successfully sent LeetCode question to ${member.user.tag}`);

// Fetch the redirect channel from the guild's cached channels
const redirectChannel = member.guild.channels.cache.get(config.LEETCODE_LOGS_CHANNEL_ID);

if (redirectChannel && redirectChannel.isText()) {
// Create an embed for better logging
const embed = new MessageEmbed()
.setColor('#00FF00') // Green color for success
.setTitle('LeetCode Question Sent')
.setDescription(`Successfully sent LeetCode question to ${member.user.tag}`)
.setTimestamp();

// Send the embed to the log channel
await redirectChannel.send({ embeds: [embed] });
console.log(`Successfully logged message to the channel: ${redirectChannel.name}`);
} else {
console.error('Redirect channel not found or is not a text channel.');
}
} catch (error) {
console.error(`Failed to send DM to ${member.user.tag}:`, error);
}
try {
// Send DM to the user with the LeetCode question
await member.user.send(
`You have been timed out in ${member.guild.name}. To get your timeout removed, solve this LeetCode question and reply with submission link or screenshot: ${randomLeetCodeQuestion}`,
);
console.log(`Successfully sent LeetCode question to ${member.user.tag}`);

// Fetch the redirect channel from the guild's cached channels
const redirectChannel = member.guild.channels.cache.get(config.LEETCODE_LOGS_CHANNEL_ID);

if (redirectChannel && redirectChannel.isText()) {
// Create an embed for better logging
const embed = new MessageEmbed()
.setColor('#00FF00') // Green color for success
.setTitle('LeetCode Question Sent')
.setDescription(`Successfully sent LeetCode question to ${member.user.tag}`)
.setTimestamp();

// Send the embed to the log channel
await redirectChannel.send({ embeds: [embed] });
console.log(`Successfully logged message to the channel: ${redirectChannel.name}`);
} else {
console.error('Redirect channel not found or is not a text channel.');
}
} catch (error) {
console.error(`Failed to send DM to ${member.user.tag}:`, error);
}
this dont
pat
pat2mo ago
"dont work" is not descriptive enough
Auth
AuthOP2mo ago
aight wait
Failed to send DM to kafkawaa: TypeError: redirectChannel.isText is not a function
at handleTimeout (/home/authtbh/mirai/libs/messageHandler.js:520:44)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.handleMemberUpdate (/home/authtbh/mirai/libs/messageHandler.js:463:7)
Failed to send DM to kafkawaa: TypeError: redirectChannel.isText is not a function
at handleTimeout (/home/authtbh/mirai/libs/messageHandler.js:520:44)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.handleMemberUpdate (/home/authtbh/mirai/libs/messageHandler.js:463:7)
its not actually dm error thats my custom error ik sucks
pat
pat2mo ago
can u log redirect channel before the if statement where u make the embed
Auth
AuthOP2mo ago
aight lemme do
TÆMBØ
TÆMBØ2mo ago
Are you actually using d.js v14.16? Because you selected the tag for it, however you have MessageEmbed in your code which makes me think you're on v13, however the error you're getting would mean that you're in fact not on v13
Auth
AuthOP2mo ago
no idea lmao lemme check "discord.js": "^14.15.3",
Auth
AuthOP2mo ago
Pastebin
TextChannel { type: 0, guild: Guild { id: '12333205 - Pasteb...
Pastebin.com is the number one paste tool since 2002. Pastebin is a website where you can store text online for a set period of time.
TÆMBØ
TÆMBØ2mo ago
Right, so: A) The method was renamed to isTextBased() B) The MessageEmbed class was renamed to EmbedBuilder
pat
pat2mo ago
sniped
Auth
AuthOP2mo ago
huh
Auth
AuthOP2mo ago
No description
Auth
AuthOP2mo ago
holy shit worked
Want results from more Discord servers?
Add your server