#What you mean how did your add it

1 messages ยท Page 1 of 1 (latest)

manic willow
#
 .then(async interaction => 
        const StartTimeInput = interaction.fields.getTextInputValue(StartTime);
            const EndTimeInput = interaction.fields.getTextInputValue(EndTime);
        const StartProofInput = interaction.fields.getTextInputValue(StartProof);
        const EndProofInput = interaction.fields.getTextInputValue(EndProof);
        const TotalTimeInput = interaction.fields.getTextInputValue(TotalTime);
#

@thorny oyster

thorny oyster
#

You need a { and }

manic willow
#

oh

#

i keep getting

#

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/Users/oerston25/Desktop/test-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:76:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
}

#
await interaction.reply(`${interaction.user.tag}, your patrol log has been submitted. You will get a notice in your Direct Messages on the status of your log.`),
        await ApproveChl.send({ embeds: [PendingEmbed] })
#

this is the only spot where i have something sent

#

@thorny oyster

thorny oyster
#

Use followUp

manic willow
#

ApproveChl.followUp ?

thorny oyster
#

No the top one

manic willow
#

Ok

thorny oyster
#

And also what is ApproveChl ?

manic willow
#

same error

#

const ApproveChl = client.channels.cache.get('1034095095261184040');

#

and it still gave the interaction already replied error when i changed it to followu[

thorny oyster
#

Show me the full code

manic willow
thorny oyster
#

Its lowercase F

#

followUp

manic willow
thorny oyster
thorny oyster
#

Your interaction event file

manic willow
thorny oyster
#

Where your put interactionCreate event ?

manic willow
# thorny oyster Where your put `interactionCreate` event ?
client.on('interactionCreate', async (interaction) => {
  try { 
    const RestrictedUsers = await Restricted.findOne({ where: { user: interaction.user.id } })
  console.log(RestrictedUsers.user)
  if (RestrictedUsers.user == interaction.user.id) return interaction.reply('no'); 
  } catch {};
  
  const command = client.commands.get(interaction.commandName);

  if (!command) return;

  try {
    await command.execute(interaction);
  } catch (error) {
    console.error(error);
    await interaction.reply({ embeds: [errorEmbed], ephemeral: true });
  }
});
thorny oyster
#

Can you show me full code of how your handle modal submit

manic willow
#

just that file

#

the cmd file

thorny oyster
#

awaitModalSubmit() thing

thorny oyster
manic willow
#

im just using a filter

thorny oyster
#

Try log interaction inside then()

#

Does it open the modal

manic willow
#

yes it does

#
ReferenceError: StartTimeInput is not defined
    at Object.execute (/Users/oerston25/Desktop/test-bot/commands/modal.js:64:28)
    at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
    at async Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:73:5)
node:events:491
#

console.log(interaction)?

#

it never submits the modal i dont think

manic willow
#

.setDescription(${StartTimeInput})

#

oh its b/c i moved the const stuff below the embed builder

thorny oyster
#

You need to put the embed below the const StartTimeInput in then()

manic willow
#

yup

#

here is the interaction

#

being logged

thorny oyster
#

Then the error ?

manic willow
#

Error [InteractionAlreadyReplied]: The reply to this interaction has already been sent or deferred.
at ChatInputCommandInteraction.reply (/Users/oerston25/Desktop/test-bot/node_modules/discord.js/src/structures/interfaces/InteractionResponses.js:102:46)
at Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:76:23)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
code: 'InteractionAlreadyReplied'
}

thorny oyster
#

Is this full error ?

manic willow
#

yes

#

thats teh code

thorny oyster
#

Why awaitPatrolModalSubmit() ?

manic willow
#

cuz thats the modal id

thorny oyster
#

What its should be awaitModalSubmit()

manic willow
#

Ok changed back and the modal doesn't submit

#

thats what logged to the console

thorny oyster
#

Can you put on srcbin

manic willow
#

๐Ÿ‘

thorny oyster
#

Log interaction.fields

manic willow
#

Ok

thorny oyster
#

Okay change your interaction.fields to interaction.fields.fields

manic willow
#

the log?

thorny oyster
#

Yes

manic willow
#

kk

thorny oyster
#

Sorry if i replied late because i use a phone xD

manic willow
#

it ok

thorny oyster
#

Now on your code change from interaction.fields.getTextInputValue() to interaction.fields.fields.getTextInputValue()

manic willow
#

OK

thorny oyster
#

Do you have a modal handler ?

manic willow
#

uhm no, i was just using a filter

thorny oyster
#

Umm are you sure because i see the code you gived it to me is just a modal builder

manic willow
#

oh ye i dont have a handler

#

i dont think

#

would i need a collector like buttons?

thorny oyster
#

Or is it a command ?

manic willow
#

i just have everything int he command

#

in the command

thorny oyster
#

Oh yeah

#

I think you need to handle the modal submit inside interactionCreate event

#
if (interaction.isModalSubmit()) {
// Further code
}
manic willow
#

oh so i put my code in there

thorny oyster
manic willow
#

Okay.

thorny oyster
#

But only the code inside .then() function

#

If you done hmu

manic willow
#

Okay

manic willow
thorny oyster
#

Nope

#

And dont forget to check

if (interaction.customId === 'PatrolLog') {
// Further code
}
manic willow
# thorny oyster Nope

if (interaction.isModalSubmit()) {
^

ReferenceError: interaction is not defined
at Object.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:84:1)
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)
at Function.executeUserEntryPoint [as runMain] (node:internal/modules/run_main:81:12)
at node:internal/main/run_main_module:23:47

#

oh

thorny oyster
#

Did you put on interactionCreate event

manic willow
#

@thorny oyster

#

this is inside index.js

thorny oyster
#

You did not put the code inside interactionCreate

manic willow
#

oh

thorny oyster
#

And also avoid nested listeners

#

Just use one listener only

manic willow
#

wdym

thorny oyster
#

Put first then ill explain to you

manic willow
#

it doesnt submit the modal now

thorny oyster
#

Show me the updated code

manic willow
thorny oyster
#

Why do you have a nested event listeners

manic willow
#

idk

thorny oyster
#

Okay basically i tell you what is nested listeners

client.on('ready', ...);

client.once(Events.ClientReady, ...);
#

Use either one only

#

If you want a bottom one then remove the first one

#

And for interactionCreate event you have another Events.InteractionCreate event nested

#

I can help you to clean the code but it takes 3 min or something if you want to

manic willow
#

yes pelase

#

that would be super apprichated

thorny oyster
#

Okay hold on

manic willow
#

Thank u

thorny oyster
manic willow
#

thank you

#

throw er; // Unhandled 'error' event
^

ReferenceError: StartTime is not defined
at Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:82:72)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21)

thorny oyster
thorny oyster
manic willow
#

Okay.

thorny oyster
#

And

#

Show me your updated command code

manic willow
thorny oyster
manic willow
#
    throw er; // Unhandled 'error' event
      ^

ReferenceError: StartTime is not defined
    at Client.<anonymous> (/Users/oerston25/Desktop/test-bot/index.js:82:65)
Emitted 'error' event on Client instance at:
    at emitUnhandledRejectionOrErr (node:events:394:10)
    at process.processTicksAndRejections (node:internal/process/task_queues:84:21)
``` i keep getting this err
thorny oyster
#

On your interactionCreate event you need to add a string on StartTime, EndTime, StartProof, EndProof and TotalTime

#

And everything set

manic willow
#

wdym add a string, i have that in my cmd file

thorny oyster
#

On your interactionCreate notice you have a StartTime

#

And so on

manic willow
#

mh,

#

mhm

thorny oyster
#

Add a string quotation like this

'StartTime'
#

You had it as ```js
// Like this
StartTime

// Change to
'StartTime'

#

Show me updated code and i tell you the line

manic willow
#

Oh alright

#

const StartTimeInput = interaction.fields.getTextInputValue('StartTime');
const EndTimeInput = interaction.fields.getTextInputValue('EndTime');

#

like this?

thorny oyster
#

Ya all of it

manic willow
#

kk

thorny oyster
#

๐Ÿ‘

manic willow
#

How would i make it so if the user doesnt have a certain role it wont let them use it

#

i know how to do that

#

but i wanna do it with role name

#

not id

thorny oyster
#

Yes

manic willow
#

has. role name => or something right?

thorny oyster
#

If you use has() need to provide an role id

manic willow
#

if (member.roles.cache.some(r => r.name('Perms')));

#

@thorny oyster that?

thorny oyster
#

No

#
r.name === 'role name here'
manic willow
#

?

thorny oyster
#

.some() not .has()

manic willow
#

yes i just chabged

thorny oyster
#

Ya

manic willow
# thorny oyster Ya
if (!interaction.user.roles.cache.some(r => r.name === 'pizza')) return await interaction.reply('u dont have perms');
#

like that?

thorny oyster
#

Ye

manic willow
thorny oyster
#

Not user

#

interaction.member

manic willow
#

k

manic willow
thorny oyster
#

You want to check if the user have or doesnt have ?

manic willow
#

has

#

if he doesnt have it

#

it says they cant use the cmd

thorny oyster
#

Then remove the ! and change to !== 'pizza'

manic willow
#

OK

#

still dont work

#
if (interaction.member.roles.cache.some(r => r.name !== 'pizza')) 
    return await interaction.reply('u dont have perms');
thorny oyster
#

Do you have pizza role ?

manic willow
#

yes

thorny oyster
#

Well then try this

const isRole = interaction.member.roles.cache.some(r => r.name === 'pizza');
console.log(isRole);

Tell me its return true or false

manic willow
#

k

#

retruned false

delicate python
#

So the member does not have the role with that name

manic willow
#

now it works fine

#

๐Ÿ˜„

thorny oyster
#

๐Ÿ‘

manic willow
#

@delicate python

#

if (interaction.member.roles.cache.some(r => r.name !== 'Parks Canada'))

#

this doesnt work

thorny oyster
#

Do the same i gived to you

manic willow
#

what is this