applied Tags
so im trying to make my bot send a message when a certain tag is applied to a thread
the tags get logged but nothing gets sent to the channel
33 Replies
• 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.are you trying to send the message inside that thread? or sending the message to another channel?
that thread
also, appliedTags is an array[]
so if there can only be one tag, itll always be appliedTags[0], if there can be multiple tags on the thread, youll need to loop thru the tags to see if the tag youre looking for exists
if (newThread.appliedTags === ['1107649018902884393'])?
or
if (newThread.appliedTags[0] === '1107649018902884393')
newThread.send({})
is usually better in my book as well, but not sure itd make any differenceoh
but yes, comparing the entire value of the array would work as well, so long as they cant select more than one tag
ok thank you
also, i dont think you can send a willy nilly ephemeral message... only in response to an interaction
yea i just realized haha
but, the message 'working' still sends even if its not the right tag im applying to the channel
for instance, i want it to send when the tag "Beginner" appears, but the message still sends when the tag "Intermediate" appears
try returning the .send() function
or
that works only if the only tag is beginner
im sorry what
is there a way to make it so that if beginner is added, regardless of what other tags are applied, sends the message?
sorry, it worked. but only if there is only one tag (beginner)
correct, thats what i was saying before. if theres more than 1 tag, youll need to loop through the array of appliedTags
ohhh ok thank you
or something alongthose lines
do i have to add the [0]
no, the [0] just means look at the first array value only.
if you console.log(newThread.appliedTags), you should see
['132456789', '987654321']
if there were 2 tags applied.
when you run
it will look at each value in newThread.appliedTags (123456789
and 987654321
), and if any of them match 123456789
, itll execute the code
also, beware that the message will likely send every time the thread is updated, because the appliedTags will be the same, since this is within the threadUpdate event.
(so if the thread is renamed, etc itll resend)
that can be avoided by comparing the oldThread.appliedTags to the newThread.appliedTagscan u
send an example im so sorry
simply comparing the two "versions" of the thread
so the 'this tag' would be the tag i want when sending the message right?
yep
for ex, beginner
@ me if you need anything else, gonna be tabbed out into a different window
perfect, thank you
@ex_1 this is a whole different thing but youre very helpful so i wanted to see if you knew the answer
i wanted to create a reminder for someone who ran a command x minutes ago- is this possible?
using a 3rd party library, like
cron
, yes.
or (a less good idea) using a timeout fuction to execute something after some timenpmjs.com/package/cron
this?
npm
cron
Cron jobs for your node. Latest version: 2.3.1, last published: a month ago. Start using cron in your project by running
npm i cron
. There are 1802 other projects in the npm registry using cron.is that against tos at all lol
depends how you use it. if you use cron to send the same message every 10 seconds, technically yes thats api abuse. but if you send a message every hour, or every day, or one time 5 minutes after a particular event, it wouldnt be api abuse
but thatd be a good question for someone else
do you use cron urself?