#Help with importing

62 messages · Page 1 of 1 (latest)

pastel dewBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

dull rivet
#

you can use

covert trench
#

use ?

#

const { randomToken } = require("../../Buttons/Verify/verify-button");```
#

i did this too

#

but didnt worked

dull rivet
#

that wont work give me asec im trynna find a doc lol

dull rivet
#

you can try using awaitModalSubmit inside the file, so you dont have to use interactionCreate event in a seperate file

#

so you get the modal submission in the file you're generating the token at and then use that to determine it

covert trench
dull rivet
#

const modalInteraction = await interaction.awaitModalSubmit({ time: 0});

#

modalInteraction.reply("Submitted")

#

that will close the modal if you reply to the interaction

covert trench
scenic coral
#

exports.randomToken = ...
const { randomToken } = require(filepath);

edgy tide
scenic coral
#

you need to export a function and pass randomString as the function parameter

covert trench
#

smth like this

function randomString (randomToken) {
        
      }```
scenic coral
#
module.exports = (randomString) => {
  return randomString
      .generate({ length: 5, charset: "hex" })
      .toUpperCase();
};
covert trench
#

uhh

#

let me try

edgy tide
#

How does that help with sharing the same randomToken with two files? It doesn’t, right. Not helpful

covert trench
#

Nope doesnt work

#

@edgy tide any idea what to do

edgy tide
#

Best idea is to handle the modal in the file you create it, as shown earlier with the awaitModalSubmit

edgy tide
# covert trench ahhh other than that

Or call the modalHandling file from there and pass the token, userId and customId there. If you don’t mind me asking what’s making you not want to handle the modal in there?

covert trench
#
 if (
      interaction.fields.getTextInputValue("veryUserInput").toUpperCase() ===
      randomToken
    ) {
      const verifyRoleId = await roleSchema.findOne({
        guildId: interaction.guild.id,
      });
      const role = interaction.guild.roles.cache.get(verifyRoleId.roleId);

      if (!role)
        return interaction.reply({
          content: "Role not found!",
          ephemeral: true,
        });

      await interaction.member.roles.add(role).then((m) => {
        return interaction
          .reply({
            embeds: [
              new EmbedBuilder()
                .setTitle("Verification Successful!")
                .setDescription(
                  `You have been verified and have been given the ${role.name} role!`
                )
                .setColor("Green"),
            ],
            ephemeral: true,
          })
          .catch((err) => {
            console.log(err);
          });
      });
    }

    if (
      interaction.fields.getTextInputValue("veryUserInput").toUpperCase() !==
      randomToken
    ) {
      interaction.reply({
        content: "You have entered the wrong code!",
      });
    }```
covert trench
#

not defined

#

getTextInputValue Not Definied

edgy tide
dull rivet
#

you have a repeating code

#

at the top

#

oh nvm

#

my bad

edgy tide
#

Nah, it‘s just a second if that could just be an else

covert trench
#

@edgy tide @dull rivet

#

this is the error

#
 interaction.fields.getTextInputValue("veryUserInput").toUpperCase() ===
                         ^

TypeError: Cannot read properties of undefined (reading 'getTextInputValue')````
edgy tide
#

No need to ping in a forum thread… it‘s only annoying

covert trench
dull rivet
#

have you converted your interaction to it?

covert trench
#

ahh my brain messed up

#

adding it to the cache

#

would work

#

?

edgy tide
#

Umm, what do you want to add to what cache?

#

And lemme again ask what holds you from using the awaitModalSubmit approach

covert trench
#
                         ^

TypeError: Cannot read properties of undefined (reading 'getTextInputValue')```
dull rivet
#

example