setInterval in an event

I would like the event to be executed every 30 seconds but somehow it does nothing and does not throw an error.
24 Replies
⚡AmirhN
⚡AmirhN3y ago
how you're getting interaction in that function? btw you could simply put it in your index.js with cron OR loop it in ur client.on('ready').
Joni
JoniOP3y ago
I also wonder how I get the interaction in it and I could put it in my Index.js but I actually want it all organized at the events so that it is clearer
Kevinnnn
Kevinnnn3y ago
Are you waiting out the full 30 seconds for the setInterval to run?
Joni
JoniOP3y ago
actually I want him to do this every 30 minutes but for testing it is 30 seconds for now I think my mistake is with the Chanel determine with the interaction but I do not know how I can fix that but eigendlich even if the channel can not be determined it should give me an error a and I've been waiting the whole 30 seconds but I think the error is in the name because it has to be triggered somehow but I don't know how it's not as easy as 'guildMemberAdd' I tried 'apiResponse' as name but it didn't work either because of de, interatction
Mac
Mac3y ago
You can just use a function for that and set it on a loop
function clearMessages(client) {
...
}
function clearMessages(client) {
...
}
and then set an interval for every 30s to this in ur ready event as Amirh said Also instead of interaction use client idk how u got interaction working there but u can
d.js docs
d.js docs3y ago
discord Guild: Get Guild read more
Mac
Mac3y ago
ignore that mb just get the channel by ID and then send it there
Joni
JoniOP3y ago
so I'll leave it in the foulder event I just don't understand what you mean exactly can you give me an example code so i can understand it
Joni
JoniOP3y ago
that works now now i only have the problem with the channel
Joni
JoniOP3y ago
SpecialSauce
SpecialSauce3y ago
The client itself has a channels cache Client looks like it’s undefined
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Joni
JoniOP3y ago
In the ready Event With a Loop Right ? Oh, so he already restarts the interval itself after the certain time?
Joni
JoniOP3y ago
that still has the problem
Joni
JoniOP3y ago
Joni
JoniOP3y ago
yes oh thank you man do you have an idea how i don't delete a certain message in the channel as if it were pinned and how do I do that I get all the messages id and insert them there is there a function that stops bulkdelete on any message? or that he does not delete the messages from certain users or from himself Yes, I understood, but I don't understand how I can implement it with actually all but above all to get and save the ids of the messeges
d.js docs
d.js docs3y ago
Documentation suggestion for @profdrjoni:method Collection#filter() Identical to Array.filter(), but returns a Collection instead of an Array.
Joni
JoniOP3y ago
Yes, the 10th was just to try it out. I would actually like to have a channel where every 30 minutes everything except the embed is deleted by the bot
d.js docs
d.js docs3y ago
method TextChannel#bulkDelete() Bulk deletes given messages that are newer than two weeks.
Joni
JoniOP3y ago
but then the embed will be deleted or not oh okay thx i try it later I have to go to an appointment now
Joni
JoniOP3y ago
like that or does a foreach have to be added?
Joni
JoniOP3y ago
like so ?
Joni
JoniOP3y ago
so all will be deleted except the ones that are pinned, right?
Joni
JoniOP3y ago
yes this works thx man
Want results from more Discord servers?
Add your server