Gua-xi
DIAdiscord.js - Imagine an app
•Created by Gua-xi on 10/26/2024 in #djs-questions
How to create a thread with user permission for viewing?
I use members.add, but I want to create the Thread With "permissionwrite"
discord.js v14.14.1
async function createThread(interaction, produtos) {
const existingThread = interaction.channel.threads.cache.find(x => x.name === `🛒・${interaction.user.username}・${interaction.user.id}`);
if (existingThread) {
const actionRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setURL(`https://discord.com/channels/${interaction.guild.id}/${existingThread.id}`)
.setLabel('Ir para o carrinho')
.setStyle(5)
);
await interaction.editReply({ content: `❌ Você já possui um carrinho aberto.`, components: [actionRow] });
return null;
}
const novaThread = await interaction.channel.threads.create({
name: `🛒・${interaction.user.username}・${interaction.user.id}`,
autoArchiveDuration: 60,
type: ChannelType.PrivateThread
});
await novaThread.members.add(interaction.user.id);
return novaThread;
}
async function createThread(interaction, produtos) {
const existingThread = interaction.channel.threads.cache.find(x => x.name === `🛒・${interaction.user.username}・${interaction.user.id}`);
if (existingThread) {
const actionRow = new ActionRowBuilder().addComponents(
new ButtonBuilder()
.setURL(`https://discord.com/channels/${interaction.guild.id}/${existingThread.id}`)
.setLabel('Ir para o carrinho')
.setStyle(5)
);
await interaction.editReply({ content: `❌ Você já possui um carrinho aberto.`, components: [actionRow] });
return null;
}
const novaThread = await interaction.channel.threads.create({
name: `🛒・${interaction.user.username}・${interaction.user.id}`,
autoArchiveDuration: 60,
type: ChannelType.PrivateThread
});
await novaThread.members.add(interaction.user.id);
return novaThread;
}
3 replies