Help with file/send

Hi, I require some help as this code doesn't work.
6 Replies
d.js toolkit
d.js toolkit2y ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
NP
NPOP2y ago
import { ButtonInteraction, EmbedBuilder, TextChannel } from "discord.js";
import confirm from "../../Modules/Confirm";
import Thread from "../../Schemas/ThreadSchema";
import discordTranscripts from 'discord-html-transcripts';

export default async (interaction: ButtonInteraction) => {
interaction.deferUpdate();

const confirmation = await confirm(
interaction,
new EmbedBuilder()
.setTitle("Pending Confirmation")
.setColor("#fffff")
.setDescription(`Are you sure you want to close this thread?`)
.setFooter({ text: "You have 60 seconds." })
);

if (confirmation?.proceed) {
const thread = await Thread.findOne({ ChannelID: `${interaction.guild.id}-${interaction.channel.id}` });
if (!thread) {
return interaction
.reply({
content: "We couldn't find the database model for this thread. Please delete the channel manually.",
ephemeral: true,
})
.catch(() => {
interaction.channel
.send(
"We couldn't find the database model for this thread. Please delete the channel manually."
)
.catch(() => {});
});
}

interaction
.reply({
content: "Closing contact thread in **5 seconds!**",
embeds: [],
components: [],
})
.catch(() => {
interaction.channel
.send("Closing contact thread in **5 seconds!**")
.catch(() => {});
});

setTimeout(async () => {
try {
const transcriptChannel = interaction.guild.channels.cache.get('940271676283838544') as TextChannel;
const attachment = await discordTranscripts.createTranscript(interaction.channel);
if (transcriptChannel) {
transcriptChannel.send({
content: "Transcript:",
files: [attachment],
})
.then(() => {
console.log("Transcript sent successfully.");
})
.catch((error) => {
console.error("Error sending transcript:", error);
});
} else {
console.error("Transcript channel not found.");
}
} catch (error) {
console.error("Error creating transcript:", error);
}

interaction.channel.delete().catch(() => {
interaction.channel
.send("I was unable to delete the channel.")
.catch(() => {});
});
thread.delete();
}, 5000);
} else {
interaction
.reply({
content: "Cancelling thread close operation.",
ephemeral: true,
})
.catch(() => {
interaction.channel
.send("Cancelling thread close operation.")
.catch(() => {});
});
}
};
import { ButtonInteraction, EmbedBuilder, TextChannel } from "discord.js";
import confirm from "../../Modules/Confirm";
import Thread from "../../Schemas/ThreadSchema";
import discordTranscripts from 'discord-html-transcripts';

export default async (interaction: ButtonInteraction) => {
interaction.deferUpdate();

const confirmation = await confirm(
interaction,
new EmbedBuilder()
.setTitle("Pending Confirmation")
.setColor("#fffff")
.setDescription(`Are you sure you want to close this thread?`)
.setFooter({ text: "You have 60 seconds." })
);

if (confirmation?.proceed) {
const thread = await Thread.findOne({ ChannelID: `${interaction.guild.id}-${interaction.channel.id}` });
if (!thread) {
return interaction
.reply({
content: "We couldn't find the database model for this thread. Please delete the channel manually.",
ephemeral: true,
})
.catch(() => {
interaction.channel
.send(
"We couldn't find the database model for this thread. Please delete the channel manually."
)
.catch(() => {});
});
}

interaction
.reply({
content: "Closing contact thread in **5 seconds!**",
embeds: [],
components: [],
})
.catch(() => {
interaction.channel
.send("Closing contact thread in **5 seconds!**")
.catch(() => {});
});

setTimeout(async () => {
try {
const transcriptChannel = interaction.guild.channels.cache.get('940271676283838544') as TextChannel;
const attachment = await discordTranscripts.createTranscript(interaction.channel);
if (transcriptChannel) {
transcriptChannel.send({
content: "Transcript:",
files: [attachment],
})
.then(() => {
console.log("Transcript sent successfully.");
})
.catch((error) => {
console.error("Error sending transcript:", error);
});
} else {
console.error("Transcript channel not found.");
}
} catch (error) {
console.error("Error creating transcript:", error);
}

interaction.channel.delete().catch(() => {
interaction.channel
.send("I was unable to delete the channel.")
.catch(() => {});
});
thread.delete();
}, 5000);
} else {
interaction
.reply({
content: "Cancelling thread close operation.",
ephemeral: true,
})
.catch(() => {
interaction.channel
.send("Cancelling thread close operation.")
.catch(() => {});
});
}
};
There's no errors The transcript message just doesnt send
d.js docs
d.js docs2y ago
Tag suggestion for @itsnp: 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
NP
NPOP2y ago
I have tried, no errors are logged.
Squid
Squid2y ago
Then add logs to see which parts of the code are being reached and which ones aren't
NP
NPOP2y ago
This is in a CloseTicketButton.ts file hm
Want results from more Discord servers?
Add your server