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
⚡AmirhN2y 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
Joni2y 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
Kevinnnn2y ago
Are you waiting out the full 30 seconds for the setInterval to run?
Joni
Joni2y 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
Mac2y 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 docs2y ago
discord Guild: Get Guild read more
Mac
Mac2y ago
ignore that mb just get the channel by ID and then send it there
Joni
Joni2y 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
Joni2y ago
that works now now i only have the problem with the channel
Joni
Joni2y ago
SpecialSauce
SpecialSauce2y ago
The client itself has a channels cache Client looks like it’s undefined
Unknown User
Unknown User2y ago
Message Not Public
Sign In & Join Server To View
Joni
Joni2y ago
In the ready Event With a Loop Right ? Oh, so he already restarts the interval itself after the certain time?
Joni
Joni2y ago
that still has the problem
Joni
Joni2y ago
Joni
Joni2y 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 docs2y ago
Documentation suggestion for @profdrjoni:method Collection#filter() Identical to Array.filter(), but returns a Collection instead of an Array.
Joni
Joni2y 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 docs2y ago
method TextChannel#bulkDelete() Bulk deletes given messages that are newer than two weeks.
Joni
Joni2y 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
Joni2y ago
like that or does a foreach have to be added?
Joni
Joni2y ago
like so ?
Joni
Joni2y ago
so all will be deleted except the ones that are pinned, right?
Joni
Joni2y ago
yes this works thx man