Really need help that no body is willing too

I was wondering if someone could help me with making a modal. I have made the Modal, but i need help with the event of ModalSubmit thing. I need it to do the profile system. And like turing the Modal into the embed after the Modal has been submitted. Can someone help me with that?
64 Replies
Sean
Sean3y ago
What DJS version?
Snortzy Gaming420
Djs v14
Favna
Favna3y ago
post is tagged 14.7.0 so...
Snortzy Gaming420
The latest version Well yeah thats right Correct?
Favna
Favna3y ago
i mean that's for you to say, like the post guidelines say, run npm ls discord.js I cannot magically spy into your system and see what version you're using
Snortzy Gaming420
Well i got "discord.js": "^14.7.1", Thats true There we go tags are now correct @Favna
Favna
Favna3y ago
I have no idea about your problem. I havent used DJS v14 really yet and when I do it's through sapphire...
Snortzy Gaming420
So what should i do about this? Cuz i get no where on my own
Favna
Favna3y ago
have you tried joining and asking in the official DJS server? discord.gg/djs
Sean
Sean3y ago
didn't see the tag
Snortzy Gaming420
Yes i did many times i have And no body is really willing or offering for to help me with this I think it was changed
Favna
Favna3y ago
I changed it from 14.7.0 to 14.7.1 but for future reference, the whole point of forum posts is to use tags so in the future be sure to check them, always
Lioness100
Lioness1003y ago
I think the general idea is:
const modal = new Modal().setComponents(...);
await interaction.showModal(modal);

const submission = await interaction.awaitModalSubmit({ time: 0 });
const someField = submission.fields.getTextInputValue('something');

const updatedEmbed = new MessageEmbed()...;
await submission.update({ embeds: [updatedEmbed] });
const modal = new Modal().setComponents(...);
await interaction.showModal(modal);

const submission = await interaction.awaitModalSubmit({ time: 0 });
const someField = submission.fields.getTextInputValue('something');

const updatedEmbed = new MessageEmbed()...;
await submission.update({ embeds: [updatedEmbed] });
Parbez
Parbez2y ago
also, use a unique identifier for awaitModalSubmit filter, or 1 user's modal submit will be resolved to other
Lioness100
Lioness1002y ago
huh, I never thought about that KEKW
Snortzy Gaming420
Is it possible for you to join my VScode and help with it? I mean ill give this a try
node:internal/modules/cjs/loader:1243
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The specified module could not be found.
\\?\C:\Users\thoma\Desktop\Bot2022\node_modules\@napi-rs\canvas-win32-x64-msvc\skia.win32-x64-msvc.node
at Module._extensions..node (node:internal/modules/cjs/loader:1243:18)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\thoma\Desktop\Bot2022\node_modules\@napi-rs\canvas\js-binding.js:63:29)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12) {
code: 'ERR_DLOPEN_FAILED'
}

Node.js v18.12.1
node:internal/modules/cjs/loader:1243
return process.dlopen(module, path.toNamespacedPath(filename));
^

Error: The specified module could not be found.
\\?\C:\Users\thoma\Desktop\Bot2022\node_modules\@napi-rs\canvas-win32-x64-msvc\skia.win32-x64-msvc.node
at Module._extensions..node (node:internal/modules/cjs/loader:1243:18)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12)
at Module.require (node:internal/modules/cjs/loader:1061:19)
at require (node:internal/modules/cjs/helpers:103:18)
at Object.<anonymous> (C:\Users\thoma\Desktop\Bot2022\node_modules\@napi-rs\canvas\js-binding.js:63:29)
at Module._compile (node:internal/modules/cjs/loader:1159:14)
at Module._extensions..js (node:internal/modules/cjs/loader:1213:10)
at Module.load (node:internal/modules/cjs/loader:1037:32)
at Module._load (node:internal/modules/cjs/loader:878:12) {
code: 'ERR_DLOPEN_FAILED'
}

Node.js v18.12.1
By the am getting this error. What does it mean?
Lioness100
Lioness1002y ago
That's a napi rs issue, look on their docs to see if your not satisfyingly all their reqs
Snortzy Gaming420
Ok i got it working. Can you help me with my Modal please? Ill send the updated code tomorrow when i wake up
Lioness100
Lioness1002y ago
Ok
Snortzy Gaming420
const { Client, ModalSubmitInteraction, EmbedBuilder, InteractionType } = require("discord.js")

module.exports = {
name: "interactionCreate",

async execute(interaction, client) {

const { type, customId, channel, guild, user, fields } = interaction

if (type !== interactionType.ModalSubmit()) return;

if (interaction.customId === 'profile-modal') {

const orientationInput = submission.fields.getTextInputValue('orientation-input');
const locationInput = submission.fields.getTextInputValue('location-input');
const aboutInput = submission.fields.getTextInputValue('about-input');
console.log({ orientationInput, locationInput, aboutInput });

const Embed1 = new EmbedBuilder()
.setColor("blue")
.setTitle("orientation")
.setThumbnail(guild.iconURL())
.setDescription(orientationInput)
.setTimestamp()
const Embed2 = new EmbedBuilder()
.setColor("blue")
.setTitle("location")
.setThumbnail(guild.iconURL())
.setDescription(locationInput)
.setTimestamp()
const Embed3 = new EmbedBuilder()
.setColor("blue")
.setTitle("about")
.setThumbnail(guild.iconURL())
.setDescription(messageInput)
.setTimestamp()

const submission = await interaction.awaitModalSubmit({ time: 0 });
await submission.update({ embeds: [Embed1, Embed2, Embed3] });
}
}}
const { Client, ModalSubmitInteraction, EmbedBuilder, InteractionType } = require("discord.js")

module.exports = {
name: "interactionCreate",

async execute(interaction, client) {

const { type, customId, channel, guild, user, fields } = interaction

if (type !== interactionType.ModalSubmit()) return;

if (interaction.customId === 'profile-modal') {

const orientationInput = submission.fields.getTextInputValue('orientation-input');
const locationInput = submission.fields.getTextInputValue('location-input');
const aboutInput = submission.fields.getTextInputValue('about-input');
console.log({ orientationInput, locationInput, aboutInput });

const Embed1 = new EmbedBuilder()
.setColor("blue")
.setTitle("orientation")
.setThumbnail(guild.iconURL())
.setDescription(orientationInput)
.setTimestamp()
const Embed2 = new EmbedBuilder()
.setColor("blue")
.setTitle("location")
.setThumbnail(guild.iconURL())
.setDescription(locationInput)
.setTimestamp()
const Embed3 = new EmbedBuilder()
.setColor("blue")
.setTitle("about")
.setThumbnail(guild.iconURL())
.setDescription(messageInput)
.setTimestamp()

const submission = await interaction.awaitModalSubmit({ time: 0 });
await submission.update({ embeds: [Embed1, Embed2, Embed3] });
}
}}
Its giving me this error `
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: interaction.ModalSubmit is not a function
at Object.execute (C:\Users\thoma\Desktop\Bot2022\Events\Modal\Profile.js:16:34)
at Client.<anonymous> (C:\Users\thoma\Desktop\Bot2022\Structures\Handlers\Events.js:23:55)
at Client.emit (node:events:525:35)
at InteractionCreateAction.handle (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\WebSocketShard.js:489:22)
at WebSocketShard.onMessage (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\WebSocketShard.js:328:10)
at callListener (C:\Users\thoma\Desktop\Bot2022\node_modules\ws\lib\event-target.js:290:14)
at WebSocket.onMessage (C:\Users\thoma\Desktop\Bot2022\node_modules\ws\lib\event-target.js:209:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v18.12.1
node:events:491
throw er; // Unhandled 'error' event
^

TypeError: interaction.ModalSubmit is not a function
at Object.execute (C:\Users\thoma\Desktop\Bot2022\Events\Modal\Profile.js:16:34)
at Client.<anonymous> (C:\Users\thoma\Desktop\Bot2022\Structures\Handlers\Events.js:23:55)
at Client.emit (node:events:525:35)
at InteractionCreateAction.handle (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\actions\InteractionCreate.js:97:12)
at module.exports [as INTERACTION_CREATE] (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\handlers\INTERACTION_CREATE.js:4:36)
at WebSocketManager.handlePacket (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\WebSocketManager.js:352:31)
at WebSocketShard.onPacket (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\WebSocketShard.js:489:22)
at WebSocketShard.onMessage (C:\Users\thoma\Desktop\Bot2022\node_modules\discord.js\src\client\websocket\WebSocketShard.js:328:10)
at callListener (C:\Users\thoma\Desktop\Bot2022\node_modules\ws\lib\event-target.js:290:14)
at WebSocket.onMessage (C:\Users\thoma\Desktop\Bot2022\node_modules\ws\lib\event-target.js:209:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

Node.js v18.12.1
@Lioness100
.
.2y ago
.... because interaction.ModalSubmit does not exist? I think it's interaction.modalSubmit
Lioness100
Lioness1002y ago
It's .isModalSubmit() Also the error is saying that there is no field called orientation-input
Snortzy Gaming420
Ok Is that means the spelling, right?
Lioness100
Lioness1002y ago
maybe
Snortzy Gaming420
Would you be able to help me with the whole Modal?
Lioness100
Lioness1002y ago
sure
Snortzy Gaming420
Ok is it okay if i invite you to my vscode? Ill try and do some coding with you. ^
Lioness100
Lioness1002y ago
No, sorry I don't have time for that
Snortzy Gaming420
Ok Well i got it working actually One thing how do i make it to where itll mention the role on the embed? ^
Lioness100
Lioness1002y ago
You can't have mentions in embeds ping, you'll have to mention the role outside of the embed to You might be able to get away with mentioning all the roles outside the embed, and then immediately editing the message as to leave only the embed
Snortzy Gaming420
Well i wanna make it like this let me get you a ss
Lioness100
Lioness1002y ago
The format for a role mention is "<@&id>", so you can either do that and concatenate the role ID, or, if you have the role object from discord.js, just concatenate it directly into a string (for example: `Hello ${role}`), and it will automatically format into a mention
Snortzy Gaming420
Ohh ok then so would i have to make the role name and id into a const? .
Lioness100
Lioness1002y ago
No, you could either just use the role id as I said above, or the entire role object For example, both of these would work:
const role = interaction.guild.roles.cache.get('...');
await interaction.reply(`<&${role.id}>`);
// or
await interaction.reply(`${role}`);
const role = interaction.guild.roles.cache.get('...');
await interaction.reply(`<&${role.id}>`);
// or
await interaction.reply(`${role}`);
Snortzy Gaming420
All i want is just have mention the role in an embed. Like the ss i showed. . But ill try that one Hi, how do u get the username of the user on a embed? I know its <user>.username but that doesnt work.
Lioness100
Lioness1002y ago
Please show code
Snortzy Gaming420
Ight And one thing After this tho
Snortzy Gaming420
SourceBin
interactionCreate.js - Modal
Instantly share your code with the world.
Snortzy Gaming420
.
Lioness100
Lioness1002y ago
That's not how string formatting works. It would be:
.setTitle(`${user.username} Profile`)
.setTitle(`${user.username} Profile`)
Also, you wrote User instead of user when declaring variables, so that will need to change
Lioness100
Lioness1002y ago
Understanding Template Literals in JavaScript | DigitalOcean
The 2015 edition of the ECMAScript specification (ES6) added template literals to the JavaScript language. Template literals are a new form of making strings…
Snortzy Gaming420
Ohh ok @Lioness100 how do you mention a member in interaction.reply?
Lioness100
Lioness1002y ago
It's the same as for a role, except it would be <@ instead of <@&
Snortzy Gaming420
nah i mean like ping the member @Lioness100 like that
Lioness100
Lioness1002y ago
I know What I said still applies
Snortzy Gaming420
await interaction.reply(`${member}`); Like that?
Lioness100
Lioness1002y ago
1. No, that's not how template literals are formed, read the article I linked 2. No, as I said in the message, it's either <@${member.id}>, or ${member}. Not a hybrid of both
Snortzy Gaming420
Hi, if am checking if a member has a specific role, how do i put these roles in an array? idk if this can be possible or not
Lioness100
Lioness1002y ago
You can use member.roles.cache.has('some_id_here') to check by id, or member.roles.cache.some((role) => ...) to check by some condition using the role object
Snortzy Gaming420
Is if(interaction.user.cache.has_role(role)) { correct? ^
Lioness100
Lioness1002y ago
no interaction.member.roles.cache.has(role.id), as I said in my message
Snortzy Gaming420
Or instead Is if(interaction.member.cache.some((role) { Ohh ok
for (role in member) {
if (interaction.member.roles.cache.has(role.id)) {
console.log('The user has the role');
for (role in member) {
if (interaction.member.roles.cache.has(role.id)) {
console.log('The user has the role');
Lioness100
Lioness1002y ago
It would be for (role in member.roles.cache.values()) But an easier way to do that (iterate through every role that both members share) would be for (role in member.roles.cache.intersect(interaction.member.roles.cache).values())
Spinel
Spinel2y ago
<:_:898645159934316565> Collection#intersect() The intersect method returns a new structure containing items where the keys and values are present in both original structures.
Lioness100
Lioness1002y ago
and then you wouldn't need any check inside the loop
Snortzy Gaming420
for (role in member.roles.cache.intersect(interaction.member.roles.cache).values()) {
if (interaction.member.roles.cache.has(role.id)) {
console.log('The user has the role');
for (role in member.roles.cache.intersect(interaction.member.roles.cache).values()) {
if (interaction.member.roles.cache.has(role.id)) {
console.log('The user has the role');
Right?
Lioness100
Lioness1002y ago
as I said, if you intersect, you won't need the check inside the loop
Snortzy Gaming420
Well it seems that it wont send the Embed
Snortzy Gaming420
SourceBin
interactionCreate.js - Profile Modal
Instantly share your code with the world.
Snortzy Gaming420
^
Lioness100
Lioness1002y ago
I can't hold your hand through everything. Do some debugging. Add some log statements and see where the bot stops doing what you want it to do.
Snortzy Gaming420
FIne ama go find some other server to ask for help, this is not working
Want results from more Discord servers?
Add your server