#Help

1 messages · Page 1 of 1 (latest)

vivid junco
#

hey, so

crystal stone
#

share your code

vivid junco
#

because right now if anyone replies to the new channel, the bot will recognize it and it won't be closed after 1h

#

it should apply only to the interaction.user

#

so anyone can reply, but if the interaction.user has not replied anything, then delete

#

if he has replied, don't delete

#

hope you get me haha

crystal stone
#

yea i get you, its kinda to really related to discord.js but im taking the freedom of being on a thread

#

you need to have some internal timers, but this is like my idea though, gimme a couple of secs while i log in on my computer

vivid junco
#

sure, thank you for helping me out 🙏

crystal stone
#

are you familiar with nodejs timers?

vivid junco
#

more or less, yes

crystal stone
#

so basically you dont want the channel to be deleted after one hour but rather be deleted if the user that used the interaction hasn't sent a message after 1 hour from their last one

vivid junco
#

if he just opened an "application"

#

and said nothing in the newly created room in one hour

#

delete it

crystal stone
#

okay so I think this is simpler than it seems at first, im trying to see if this would work, im too lazy to test...
first after you create the channel, you could create the first timeout like this

let deleteChannelTimeout = setTimeout(() => {
  // whatever you want to do if the channel has to be deleted

  c.delete("No response");
}, waitAmount);```

So what i would do is, after you create the channel, create a messageCollector on the channel like this
`c.createMessageCollector().on('collect', message => {`
then inside the collector, check `if (message.author.id === interaction.user.id) {`, if this is true it means the user who issued the interaction sent a message to this channel, so we can reset the timer clearing the timeout ` clearTimeout(deleteChannelTimeout);` and then creating a resetting it like this
`deleteChannelTimeout = setTimeout(() => { c.delete("No response given within 1 hour") }, waitAmount);`

in my head this should work, that doesn't mean in practice it will, but you can get an idea out of this, just make sure you clear the timeouts correctly otherwise it will go to shit
#

this would only be for the part of them not sending a message for one hour in the channel