Replies: 2 comments 3 replies
-
Listen to Events do some Advanced Stuff {
id()
const userId = "" // Target user ID
const search = [`I'm afk`,`are you busy?`]
const channelId = cid
let message = [`Ok...`,`yeah im busy dude`]
const seenMessagesIds = new Set()
var loop = true
var i = 0;
while (loop) {
const messages = await api.getMessages(channelId, 10) // You can edit limit.
const found = messages.filter(msg => msg.content.includes(search[i]) && !seenMessagesIds.has(msg.id) && msg.author.id === userId )
if (found.length > 0) {
for (const msg of found) {
console.log(`Found message ID=${msg.id} "${msg.content}" by ${msg.author.username}#${msg.author.discriminator} ID=${msg.author.id}`)
seenMessagesIds.add(msg.id)
const sent = await api.replyToMessage(msg.channel_id, msg.id, message[i]) // Sendin reply to message.
seenMessagesIds.add(sent.id)
await api.delay(3*1000) // wait 3 seconds, you can edit delay.
}
}
i = (i + 1) % search.length
}
} to stop write |
Beta Was this translation helpful? Give feedback.
2 replies
-
{
// AFK message
const afkMessage = 'Hi, I am currently AFK. I will reply to your message as soon as I am back.'
// Init - Store all recent DMs IDs
const seenDMs = new Set()
let DMs = await api.getDMs()
DMs.forEach(DM => seenDMs.add(DM.last_message_id))
// Check every 10 seconds for new DMs
var loop = true
while (loop) {
DMs = await api.getDMs()
DMs = DMs.filter(DM => !seenDMs.has(DM.last_message_id))
// Reply to each new DMs, wait 1s between each
for (const DM of DMs) {
seenDMs.add(DM.last_message_id)
console.log(`New DM from ${DM.recipients[0].username}#${DM.recipients[0].discriminator} (${DM.recipients[0].id})`)
const sentMessage = await api.sendMessage(DM.id, afkMessage)
seenDMs.add(sentMessage.id)
await delay(1000)
}
await delay(10000)
}
} |
Beta Was this translation helpful? Give feedback.
1 reply
Answer selected by
Fluffaro
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
how can i make it if someone dms me a message it will say "I'm afk"
Beta Was this translation helpful? Give feedback.
All reactions