1

If anyone could help would be great im running into two errors, one the catch is not working correctly probably because of the try but I dont know how to fix it, two I want to know the code for the newly created channel, as I want to send the embedParent to the newly created ticket. Again I am new to this stuff...

client.on('message', message => {

    let args = message.content.substring(PREFIX.length).split(' ');

    switch (args[0]) {
        case 'ticket':

    // ID from the catogory channel tickets.
    const categoryId = "644626077704257546";

    // Get username
    var userName = message.author.username;
    // Verkrijg discriminator
    var userDiscriminator = message.author.discriminator;

    // If ticket has been made
    var bool = false;


    // Ticket return code
    if (bool == true) return;

    var embedCreateTicket = new Discord.MessageEmbed()
        .setTitle("Hey, " + message.author.username)
        .setFooter("Support channel will be made");

    message.channel.send(embedCreateTicket);

    // Create channel and put it in the right catogary
    message.guild.channels.create(userName + "-" + userDiscriminator, "text").then((createdChan) => { // Maak kanaal

        createdChan.setParent(categoryId).then((settedParent) => { // Zet kanaal in category.

            // Put permissions for everyone
            settedParent.overwritePermissions(message.guild.roles.find('name', "@everyone"), { "READ_MESSAGES": false });
            settedParent.overwritePermissions(message.guild.roles.find('name', "@management"), { "VIEW_CHANNEL": true });
            // Put permission by the user that created the ticket
            settedParent.overwritePermissions(message.author, {

                "READ_MESSAGES": true, "SEND_MESSAGES": true,
                "ATTACH_FILES": true, "CONNECT": true,
                "CREATE_INSTANT_INVITE": false, "ADD_REACTIONS": true

            });
            settedParent.overwritePermissions(everyone, {

                "READ_MESSAGES": false, "SEND_MESSAGES": false,
                "ATTACH_FILES": false, "CONNECT": false,
                "CREATE_INSTANT_INVITE": false, "ADD_REACTIONS": false

            });

            var embedParent = new Discord.MessageEmbed()
                .setTitle("Hey, " + message.author.username.toString())
                .setDescription("Put down here your question");

            channel.new.send(embedParent);            
            });try {error} finally
                
            {err => {
            message.channel.send("Something went wrong.");
        };

    }try {
        
    }catch (error) {
        
    }(err => {
        message.channel.send("Something went wrong.");
    });
}
    
)
    }
}
)
  • Could you tell us what errors you run into exactly? – wgumenyuk Oct 07 '20 at 20:06
  • So its not exactly a error its just im running into it where I cant figure out how to send the embed to the created chan. – Harrison Clamp Oct 07 '20 at 20:54
  • I think, for one, you're confusing a [try...catch](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Statements/try...catch) with a [Promise.then()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/then) and a [Promise.catch()](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Promise/catch) – T. Dirks Oct 08 '20 at 06:32

0 Answers0