Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- const {SlashCommandBuilder, PermissionsBitField, EmbedBuilder} = require('discord.js');
- module.exports = {
- data: new SlashCommandBuilder()
- .setName('create-thread')
- .setDescription('create a thread')
- .addStringOption(option => option
- .setName('name')
- .setDescription('Name of the thread')
- .setRequired(true)
- )
- .addStringOption(option => option
- .setName("reason")
- .setDescription("Reason for creating this Thread")
- .setRequired(false)
- ),
- async execute (interaction, client) {
- const errEmbed = new EmbedBuilder()
- .setTitle("ERROR")
- .setColor("Red")
- .setDescription("Missing Permissions: Create Public Threads")
- .setTimestamp()
- if(!interaction.member.permissions.has(PermissionsBitField.Flags.CreatePublicThreads)) return await interaction.reply({embeds: [errEmbed], ephemeral: true});
- const { options } = interaction;
- const name = options.getString('name');
- const reason = options.getString("reason") || "No reason given!";
- const thread = await interaction.channel.threads.create({
- name: `${name}`,
- autoArchiveDuration: 60,
- }).catch(err => {
- return;
- });
- const embed2 = new EmbedBuilder()
- .setTitle("Created Thread successfull!")
- .addFields(
- {name: "Thread:", value: `<#${thread.id}>`, inline: true},
- {name: "Member:", value: `<@${interaction.member.id}>`, inline: true},
- {name: "Reason:", value: `${reason}`, inline: true}
- )
- .setTimestamp()
- .setColor("Green")
- const threadID = thread.id;
- const ThreadSend = client.channels.cache.get(`${threadID}`);
- const embed3 = new EmbedBuilder()
- .setTitle("Your Thread has been created!")
- .setColor("Green")
- .setDescription("This is your Thread!")
- .addFields(
- {name: "Reason", value: `${reason}`}
- )
- .setTimestamp()
- ThreadSend.send({
- content: `<@${interaction.user.id}>`,
- embeds: [embed3]
- }).catch(err => {
- return;
- })
- await interaction.reply({
- embeds: [embed2]
- }).catch(err => {
- return;
- });
- }
- }
Advertisement
Add Comment
Please, Sign In to add comment