#Help with importing
62 messages · Page 1 of 1 (latest)
you can use
use ?
const { randomToken } = require("../../Buttons/Verify/verify-button");```
i did this too
but didnt worked
that wont work give me asec im trynna find a doc lol
k
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
that thing doesnt close the modal
It does, if you reply to the modal
const modalInteraction = await interaction.awaitModalSubmit({ time: 0});
modalInteraction.reply("Submitted")
that will close the modal if you reply to the interaction
let me try
exports.randomToken = ...
const { randomToken } = require(filepath);
That won’t work since they make a new randomToken for every modal invocation probably
ye
you need to export a function and pass randomString as the function parameter
?
elobrate
smth like this
function randomString (randomToken) {
}```
module.exports = (randomString) => {
return randomString
.generate({ length: 5, charset: "hex" })
.toUpperCase();
};
How does that help with sharing the same randomToken with two files? It doesn’t, right. Not helpful
Best idea is to handle the modal in the file you create it, as shown earlier with the awaitModalSubmit
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?
ahh this thing
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!",
});
}```
that shows js interaction.fields.getTextInputValue("veryUserInput")
not defined
getTextInputValue Not Definied
Does it say that’s not defined? Or is it trying to access that property of undefined? Because interaction is no ModalSubmitInteraction then
Nah, it‘s just a second if that could just be an else
@edgy tide @dull rivet
this is the error
interaction.fields.getTextInputValue("veryUserInput").toUpperCase() ===
^
TypeError: Cannot read properties of undefined (reading 'getTextInputValue')````
No need to ping in a forum thread… it‘s only annoying
sry
👆
yep its not in ModalSumbitIntraction
have you converted your interaction to it?
Umm, what do you want to add to what cache?
And lemme again ask what holds you from using the awaitModalSubmit approach
this thing
^
TypeError: Cannot read properties of undefined (reading 'getTextInputValue')```
If you get that error, it means you haven't converted your interaction into ModalSubmitInteraction
example