Embed Channel Not Found

Hello, I've been working with Discord.js for a few days making the switch from discord.py I'm having an issue on my ban command that isn't on my on_ready command This is my current code:
try {
await interaction.deferReply();

await interaction.guild.members.ban(userToBan, { reason: reason });

const banEmbed = new EmbedBuilder()
.setColor(0xFF0000)
.setTitle('Discord Log // Banned')
.setDescription(`Ran by ${interaction.author}\nActual Command Finish: ${userToBan.tag} was banned.\nReason: ${reason}`)

const channel = interaction.guild.channels.cache.get(1160603215432265768);
if (channel) {
channel.send({ embeds: [banEmbed] });
} else {
console.error('Channel not found!');
}

await interaction.followUp(`User ${userToBan.tag} was banned.\nReason: ${reason}`);
} catch (error) {
console.error('Error banning member:', error);
await interaction.followUp({ content: 'An error occurred while banning the member.', ephemeral: true });
}
try {
await interaction.deferReply();

await interaction.guild.members.ban(userToBan, { reason: reason });

const banEmbed = new EmbedBuilder()
.setColor(0xFF0000)
.setTitle('Discord Log // Banned')
.setDescription(`Ran by ${interaction.author}\nActual Command Finish: ${userToBan.tag} was banned.\nReason: ${reason}`)

const channel = interaction.guild.channels.cache.get(1160603215432265768);
if (channel) {
channel.send({ embeds: [banEmbed] });
} else {
console.error('Channel not found!');
}

await interaction.followUp(`User ${userToBan.tag} was banned.\nReason: ${reason}`);
} catch (error) {
console.error('Error banning member:', error);
await interaction.followUp({ content: 'An error occurred while banning the member.', ephemeral: true });
}
This error I'm getting is my console.error('Channel not found!'); - It bans the person and gives me the reason in the chat but says the channel is somehow not found. I'm thinking it has something to do with const channel = interaction.guild.channels.cache.get(1160603215432265768); but I'm not 100% sure.
5 Replies
d.js toolkit
d.js toolkit15mo 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
Slothy
SlothyOP15mo ago
[email protected] - Node v18.18.0
treble/luna
treble/luna15mo ago
Snowflakes are strings Not numbers
Slothy
SlothyOP15mo ago
Ah! I through it in '' let me try it real fast
Slothy
SlothyOP15mo ago
It worked wonders! I know how to fix the ran by - Thanks for the help, @wolvinny 👻🌈 ❤️
No description
Want results from more Discord servers?
Add your server