#Delete channel after X days inactivity

99 messages · Page 1 of 1 (latest)

thin lightBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

kind hemlock
#

i’m on latest node & DJS

thin lightBOT
kind hemlock
#

i know how to take the last timestamp

slim needle
kind hemlock
#

but i don’t know how to check if the last message is 3 days

#

i want to do :

3 days inactivity auto close but how i can check if the last message is sended after 3 days for close the channel?

thin lightBOT
slim needle
#

get timestamp from this, then compare it to current date

kind hemlock
#

i have try but i don’t know how to compare it

slim needle
#

SnowflakeUtil.timestampFrom(id)
just compare that

hushed river
kind hemlock
hushed river
#

That will always be a negative number then

kind hemlock
#

so i do SnowflakeUtil.timestampFrom(message timestamp) that's right ?

#

and it's say the timestamp passed

oblique peak
kind hemlock
#

euh yes sure

#

i want to do this verification all 5 minutes how i can check all channel ?

#

all channel contains "X" in the name

#

of my guild

oblique peak
#

<GuildChannelManager>.filter(ch => ch.name.includes('string'))

#

and setInterval()

kind hemlock
#

yes this i know

#

that's just for take all channel

#

thx i'm going try this ^^

oblique peak
#

but if you want to check the inactivity of the channel every x days wouldn’t be better to put this interval every x days

kind hemlock
#

yes but that(s a ticket system

#

and i search for 30 min inactivity channel state change

#

wait

#

I have category active channel

#

and inactive

#

i want to set inaxtive after 30m ,o message

#

the channel is set active when a message is sended

#

that's why 5 minutes

kind hemlock
ocean tundra
#

@kind hemlock Highly recommend typescript

kind hemlock
ocean tundra
#

Parse error near "don't another method"

kind hemlock
oblique peak
kind hemlock
kind hemlock
# oblique peak .cache.filter
const filter = guild.channels.cache.filter(ch => ch.name.includes('aide')) 

      filter.messages.fetch({ limit: 1 }).then(messages => {
        let lastMessage = messages.first();

        console.log(lastMessage.id)
        
        if (!lastMessage.author.bot) {
          return; 
        }
      }).catch(console.error);

    }, 1 * 60 * 1000) // 1 minute(s)
oblique peak
kind hemlock
#

and how i can define all channel includes "aide" for set the last message sended ?

oblique peak
#

for (const channel of channels.values()) ... or <Collection>.forEach()

#

and try getting the last message from <TextChannel>.lastMessage

kind hemlock
#
setInterval( function() {

      const filter = guild.channels.cache.filter(ch => ch.name.includes('aide')) 
      const channel = filter.forEach();

      const lastMsg = channel.lastMessage();
      console.log(lastMsg.id);

    }, 1 * 60 * 1000) // 1 minute(s)
hushed river
kind hemlock
#
guild.channels.cache.filter(ch => ch.name.includes('aide')).forEach(chan => {
        console.log(chan);
      });
#

rn i do chan.lastMessage right ?

kind hemlock
#

mhhh

#

I have try with this

hushed river
# kind hemlock

discord.js exports SnowflakeUtil itself. And that has the exact function. Where did you import it from?

kind hemlock
#

thx

#

and now how i can check if

#

is inactive by x days ?

#

or x hours

slim needle
#

you... subtract that from Date.now()...

kind hemlock
slim needle
#

uh what

kind hemlock
#

that's say 53 years ago

slim needle
#

Assuming that this timestamp is in seconds

#

that's in ms

kind hemlock
#

mhhh

kind hemlock
# slim needle that's in ms

Timestamp message : 1665251587294 | Current : 1665253548328 Substract : -1961034
Timestamp message : 1665181841894 | Current : 1665253548329 Substract : -71706435
Timestamp message : 1665253272448 | Current : 1665253548329 Substract : -275881
Timestamp message : 1665251947507 | Current : 1665253548330 Substract : -1600823

#

but with the result

#

how i can know that's 1 hour ago

slim needle
#

you... subtract

kind hemlock
#

i'm fucking noob in djs 14 and also with timestamp

kind hemlock
#

that's the result

#

but i don't know i can know that's 1 hour ago for ex

slim needle
#

<t:1665252179>

#

is that when the message was sent

kind hemlock
thin lightBOT
#

Message formatting (mentions, timestamps, emoji, etc.): learn more

kind hemlock
#

i know in the code but no in text

#

thx

kind hemlock
#

highter or =

#

and i have my system

#

right ?

#

because 3,600,000 ms = 1 hour

hushed river
kind hemlock
#

Thanks that's working !

#

it's good for me