#Delete channel after X days inactivity
99 messages · Page 1 of 1 (latest)
i’m on latest node & DJS
BaseChannel#createdTimestamp
The timestamp the channel was created at
i know how to take the last timestamp
when specifying your versions, please use exact versions. Thanks
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?
TextBasedChannel#lastMessageId
The channel's last message id, if one was sent
get timestamp from this, then compare it to current date
i have try but i don’t know how to compare it
SnowflakeUtil.timestampFrom(id)
just compare that
They are numbers, what part of comparing numbers is confusing?
before when i have try it i try to create a var with the current date const x = new Date.now() and after
Time message - x
That will always be a negative number then
so i do SnowflakeUtil.timestampFrom(message timestamp) that's right ?
and it's say the timestamp passed
message id not timestamp
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
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
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
mhhh i'm so bad ? x)
@kind hemlock Highly recommend typescript
guild.channels is a https://discord.js.org/#/docs/discord.js/main/class/GuildChannelManager
don't another method in js ?
Parse error near "don't another method"
i don't understand mdmr
.cache.filter
yes i have find lmao i'm not djs dev v14
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)
filter is a Collection of all channel that includes "aide" in their names
a bruh
and how i can define all channel includes "aide" for set the last message sended ?
for (const channel of channels.values()) ... or <Collection>.forEach()
and try getting the last message from <TextChannel>.lastMessage
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)
Do you know how forEach works? If no: learn basic JS, #resources has some good links
If yes: use it correctly then
i'm tired lmao sry
guild.channels.cache.filter(ch => ch.name.includes('aide')).forEach(chan => {
console.log(chan);
});
rn i do chan.lastMessage right ?
mhhh
I have try with this
discord.js exports SnowflakeUtil itself. And that has the exact function. Where did you import it from?
oh i have don't think this
thx
and now how i can check if
is inactive by x days ?
or x hours
you... subtract that from Date.now()...
uh what
that's say 53 years ago
mhhh
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
you... subtract
i'm fucking noob in djs 14 and also with timestamp
Substract : -1600823
that's the result
but i don't know i can know that's 1 hour ago for ex
well, you could Date.now() - x
x is whatever the difference is
<t:1665252179>
is that when the message was sent
how u do this in discord ?
Message formatting (mentions, timestamps, emoji, etc.): learn more
so now i check if this is highter than 3,600,000 ms
highter or =
and i have my system
right ?
because 3,600,000 ms = 1 hour
Yes