Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

328
Views
Uncaught TypeError TypeError: *** is not a function js v13

My goal is to make a menu selection system that opens tickets. However, when it opens a ticket the roles that should have access to the tickets (admin and moderator) are not accessible. Could you help me?

Here is the code:

Client.on("interactionCreate", interaction => {

    if(interaction.isSelectMenu()){

        if(interaction.customId === "select") {
            console.log(interaction.values);

            if(interaction.values == "qst"){
                interaction.reply({content: "Vous avez choisi l'option ❓ | Question", ephemeral: true});

                nbTicket++;

                //Nom du ticket
                interaction.guild.channels.create("ticket-" + nbTicket, {
                    parent: "978962595971211324",
                    
                    //Permissions
                    permissionOverwrites: [
                        {
                            id: interaction.guild.id,
                            deny: [Discord.Permissions.FLAGS.VIEW_CHANNEL]
                        },
                        {
                            id: interaction.user.id,
                            allow: [Discord.Permissions.FLAGS.VIEW_CHANNEL]
                        },
                        {
                            id : interaction.guild.roles.cache("978963146364563456"),
                            allow: [Discord.Permissions.FLAGS.VIEW_CHANNEL]
                        }
                    ]
                }).then(channel => {
                    var button = new Discord.MessageActionRow()
                        .addComponents(new Discord.MessageButton()
                            .setCustomId("close-ticket")
                            .setLabel("Fermet le ticket")
                            .setStyle("DANGER")
                        );

                    //Message du bot à l'open du ticket
                    channel.send({content: "<@" + interaction.user.id + "> a ouvert un ticket de la catégorie ❓ | Question", components: [button]});

                    //Remise à 0 
                    interaction.update("Sélectionnez une option pour ouvrir un ticket");

                });
            }

This is the error I get:

Uncaught TypeError TypeError: interaction.guild.roles.cache is not a function

Thank you and have a nice day !

about 4 years ago · Juan Pablo Isaza
1 answers
Answer question

0

RoleManager.cache isn't a function, it's a getter, that returns Collection<Snowflake, Role>.

Probably what you are looking for is

interaction.guild.roles.cache.get("978963146364563456")

instead of

interaction.guild.roles.cache("978963146364563456")

See Collection.get

about 4 years ago · Juan Pablo Isaza Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!