MD
DIAdiscord.js - Imagine an app
•Created by MD on 8/5/2023 in #djs-questions
Bot posts randomly 1 - 3 welcome messages for the same member that already joined.
Lets start from my debugging results. First i wanted to make sure i have only one instance of the bot, so i added console.trace right before send message line, and it logs only once with nothing unusual in the trace stack. Then i made prefix "test" command that should reply multiple times if bot is in more than one instance, but also in this case, every time i get only one reply.
There is no specific pattern how bot sends welcome messages, its always between 1 - 3 messages for the same person. If two people join within 2 minutes bot can post three messages for first person, and one for second person. Bot doesn't crash or anything (I use Sentry for detailed logs). I am hosting this bot on DigitalOcean, same as my other 3 bots, but only one have that issue.
I am also sure that this is not related with my event handler, because all other events works fine.
I ran out of ideas, I even reseted bot token, but problem still exists.
What is even more weird that issue does not exists on dev version of the bot. The only difference is the token, (i use Windows WSL configured exactly the same as DigitalOcean server to host bot locally on my PC)
I put the console logs in every function that is related with guildMemberAdd event, and didn't see anything wrong (on every step i also log the new joined member, and that member is logged everywhere only once)
Is there anything else i can do? Is it possible that it is Discord API issue, server configuration or PM2? (in pm2 configuration file i have also explicitly 1 application instance)
Node.js: 18.14.0
Runtime: [email protected]
discord.js 14.11.0
OS: Ubuntu 20.04 LTS
95 replies
DIAdiscord.js - Imagine an app
•Created by MD on 3/4/2023 in #djs-questions
Check if guild member can use slash command.
I want to send ephemeral reply message with listed only slash commands (commands mentions), that guild member can use, and skip slash commands that member can not use in specific guild. That message is supposed to look different for every member, base on role and member permission overrides set up by guild administrator.
My goal is to create command check similar to this chart: https://cdn.discordapp.com/attachments/697138785317814292/1042878162901672048/flowchart-for-new-permissions.png
I figured out i can fetch command overrides like this:
but it returns collection of overrides for channels, roles and users.
Is there any better way to check if member has permission to use slash command, instead of check if any member's role has permission to use slash command, and then if that specific member has permission?
6 replies