discord.js error
Archiviert a year ago
F
filebrute_
Active!
TypeError: Cannot read properties of undefined (reading 'create')
at createTicket (C:\Users\Admin\Desktop\Coding\Opnium\OpniumTicketSystem\index.js:99:43)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async Client.<anonymous> (C:\Users\Admin\Desktop\Coding\Opnium\OpniumTicketSystem\index.js:63:24)
```js
async function createTicket(forumChannel, user, ticketType, interaction) {
console.log('Creating ticket in forum channel:', forumChannel);
if (!forumChannel || forumChannel.type !== ChannelType.GuildForum) {
throw new Error("Invalid forum channel.");
}
const threadsManager = forumChannel.threads;
if (!threadsManager) {
throw new Error("Threads manager is undefined.");
}
console.log(`Threads manager available: ${threadsManager}`);
try {
const thread = await threadsManager.create({
name: `[OPEN] - ${user.username} - ${ticketType}`,
autoArchiveDuration: 1440,
reason: `New ${ticketType} ticket from ${user.username}`,
message: {
content: `Hello ${user}, this is your ${ticketType.toLowerCase()} ticket. Our team will assist you shortly.`,
},
});
await thread.permissionOverwrites.create(user.id, {
ViewChannel: true,
SendMessages: true,
ReadMessageHistory: true,
});
return thread;
} catch (error) {
console.error('Error creating thread:', error);
throw error;
}
}```
