#message does not get sent upon role add
1 messages · Page 1 of 1 (latest)
You could just check <Member>.premiumSince
<:_:851461487498493952> GuildMember#premiumSince
The time of when the member used their Nitro boost on the guild, if it was used
Also, remove the client from the event parameters
Or nvm, realized it’s a handler
Make sure you have GUILD_MEMBERS and the GUILDS intent
Is there any errors?
Add a log at the top of the event function
See if it runs
the guildMemberUpdate event right
Yes
ok
im just asking to test the actual function of it
let channel = newMember.guild.channels.cache.get('846618764409307156') //776185536107905075
if(!channel) channel = newMember.guild.channels.cache.get('847652885691891722')
if (newMember.premiumSince && channel) {
client.channels.cache.get(channel).send(`Thank you ${newMember} for boosting our server!`)
}
``` thats what i have rn
i could prob do channel.send
idk
channel is an id tho?
yea lol
Yea, send using the channel
Run the command twice I guess
command?
lmao
Yea, that’ll be tough
client.emit("guildMemberUpdate", { guild }, { guild, premiumSince: new Date() })
whats that?
Preferably you would use an eval command to run it
uh what
so i would like throw it into a test command
and run that and see if the code works?
That would work too
alr lemme try
Make sure to define guild tho
alr
@nimble baneso what i do is run the command and if things go right, it will send the message?
Yea
alr
ok it sent this
"Thank you [Object Object] for boosting our server!"
in the correct channel
so if someone boosts then the [Object Object] thing will be the user right
alr thx
btw the client.emit thing
that pretty much just emits the certain event u want right
Yea
so would u mind like breaking down the client.emit("guildMemberUpdate", { guild }, { guild, premiumSince: new Date() }) thing?
ik the part in the " " is the actual event
but whats the other stuff?
It’s just the arguments for the guildMemberUpdate event
Making an actual Member object is overkill since you only use the guild and premiumSince props
So mock-up objects were used in place of actual Members
ah
is there a way to like delete a message without the promise?
like send it and then delete it a few secs after
ik im doing await
module.exports = {
type: 'messageCreate',
description: 'auto replies in promotion channels',
execute: async (message) => {
if(message.author.bot){
return;
}
if(['832485702888456222', '838995265649115146'].includes(message.channel.id)){
try {await message.reply("If you leave this server, all of your promotion messages will be deleted.").then(m => {
setTimeout(async () => {
{ await m.delete(); }
}, 30 * 1000)
})
} catch (error) {
console.log(error)
}
}
}
}
``` i wanna do sumn like this but ik the .then wont work
im asking cause randomly ill get an api error saying Unknown Message
and it kills the bot process
so i wanna catch the error and just do nothing with it
const timer = require("timers/promises")
const m = await reply(…)
await timer.setTimeout(time)
await m.delete()```
I hope I spelled the package name correctly
await reply is the message.reply right
Yea
ah ok
for setTimeout
do i just put the number?
or do i actually gotta make the function
ok this is what i put
lmk if its right
module.exports = {
type: 'messageCreate',
description: 'auto replies in promotion channels',
execute: async (message) => {
const timer = require('timers/promises')
const m = await message.reply("If you leave this server, all of your promotion messages will be deleted.")
if (message.author.bot) {
return;
}
if (['832485702888456222', '838995265649115146'].includes(message.channel.id)) {
try {
await timer.setTimeout(30 * 1000)
await m.delete()
} catch (error) {
console.log(error)
}
}
}
}
@nimble bane
what u think?'
hey @celest stag
hi
did you finish this code?