Bass
DIAdiscord.js - Imagine an app
•Created by Bass on 6/25/2024 in #djs-questions
End StringSelectMenu Collector (to avoid Unknown Interaction or InteractionAlreadyReplied)
Hi,
I have a command which use a StringSelectMenu and Buttons. When the command is over, if I use it again I have an error InteractionAlreadyReplied or Unknown Interaction. I think the problem comes from the StringSelectMenu because if I wait I see it disabling itself. I aim to end this collector (and not the buttons which are useful after selection) to avoid errors if I use the command again (and without have to put a 45secs cooldown for the command) but I don't really know how achieve that.
If someone has an idea it would be great
Thx by advance
Code: https://sourceb.in/OxOZFJiZOU
4 replies
DIAdiscord.js - Imagine an app
•Created by Bass on 6/19/2024 in #djs-questions
Shop with pages update too slow
Hi,
i have a command for a shop with items that users can buy. I want to be able to add and remove items so the command don't have pre-coded items and grab them in a model. If they are too many items it create a new page of the shop with button.
Currently, it's working but it's very slow, like when I change page new buttons are disabled for like 2-3 seconds which is not smooth at all. Does someone have an idea to make this better ?
Thx by advance
Code: https://sourceb.in/t5o73LacQE
4 replies
DIAdiscord.js - Imagine an app
•Created by Bass on 6/2/2024 in #djs-questions
Trying to cycle embed with pictures and confirm, but have errors
Hi everybody,
First, here his my code:
https://sourceb.in/ZcNpnYRC32
I'm currently trying to make a command, this is what I aim to do:
* This command aim to help users to custom their character sheet (which will be displayed with an other command with napis-canva) by displaying a first menu which make them choose between 3 types of assets (which they own in a mongoDB database but it's not the problem here), currently it's 3 types (backgrounds, avatar mask and embedcolor) but I'll soon remove the possibility to modify the embed color because the final picture will not be in an embed anymore.
* When the asset type is chosen, the assets owned by the user are displayed in an embedBuilder with some buttons, this way the user can see the different pictures he owns and choose one with a confirmation button
When choice is made, the bot update the database with the chosen asset.
For more technical details, the bot take in a first model database the assets from the User, and then update it in the activeCharacter database (which is an other model)
Here are the problems I'm encountering:
* When I try to confirm the asset I want, I have very briefly the confirmation message ("Selection confirmed!") and then like 0.5 sec later the error message et an error "Interaction has already been acknowledged". However, the asset is well updated in my database. Here is the complete error: https://sourceb.in/YQ3d6m0ONl (I replaced my personnal datas with .. so it's easier to read)
* When I try to change page (to see the next asset in my inventory) the next asset is well displayed but I have an error DiscordAPIError[10062]: Unknown interaction
In both cases, the bot crash. Here is the complete error: https://sourceb.in/ICZTGJaNpd (I replaced my personnal datas with .. so it's easier to read)
I know I clearly do something wrong here, but I don't find where and why and I can't get through this. If someone has time to help me I would be grateful
Thx by advance and don't hesitate if you have questions or if you need more details.
2 replies
DIAdiscord.js - Imagine an app
•Created by Bass on 4/28/2024 in #djs-questions
Confirmation and error messages problem:
Hi everybody
I'm currently trying to make a slash command with 4 subcommands:
The first creates a new role and adds users within it
The second allow to add people in roles
The third removes people from roles
The fourth and last delete the selected role
The command does what I expect. It aims to allow people to create custom roles and add many users so they can @ that role when they want instead of mention all the members of that group each time they have to speak to them. With the bot, I don't have to manage this myself, and member can do it by themselves.
The problems comes when I want to put an error message: if a user try to manage admin role for exemple, Discord API doesn't allow it (which is exactly what I want, no problem with that) but in my chat I have a confirmation message like if the command worked, but it actually not. Beyond the problem if this command, it will be a big problem if I'm not able to create simple confirmation message when the command works and an error message if it's not.
So here is my code for one of the subcommands, but the problem is the same for the 3 others (case is in french, I translated console.error + interactions). I don't post it directly because discord doesn't display it properly but if you want the whole code just tell me I'll do a pastebin :
https://i.imgur.com/s1i9Acz.png
When I use
interaction.reply
line 100 I get
DiscordAPIError[40060]: Interaction has already been acknowledged
pointing at node_modules\@discordjs\rest\dist\index.js:722:13
And if I use interaction.followUp
:
Error [InteractionNotReplied]: The reply to this interaction has not been sent or deferred.
I also tried to put a try...catch but it's exactly the same way
Actually, I could do this role attribution myself, but I'm not done with slash commands creation and if I don't understand how manage confirmation and error messages I'll get in trouble anyway.
If I delete the confirmation embed to see what it does, it prints the confirmation embed of the next subcommand so I'm sure I did something wrong (for not to say I totally messed up, I'm not a developper but I try to learn) with the embed place and the if/else, but after many researchs I don't manage to understand how to correct this, so I turn to you.
Thx by advance5 replies