Apokalypt
Apokalypt
DIAdiscord.js - Imagine an app
Created by Apokalypt on 7/4/2024 in #djs-questions
My bot seems to not received the event "interactionCreate" from button sent in DM
Forgot to answer but the event is created after I've made new Client(...) (and before login) and the listener is created because I receive interaction from commands
11 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 7/4/2024 in #djs-questions
My bot seems to not received the event "interactionCreate" from button sent in DM
The message is sent and THEN the user is banned/kick from the guild. The button was put to allow the user to contest the sanction later but I think I can't do that 😭
11 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 7/4/2024 in #djs-questions
My bot seems to not received the event "interactionCreate" from button sent in DM
Oh wait.... If the user and my bot doesn't share a server in common, my bot can receive interactionCreate events and answer ? Or is it same as messages and it's blocked ?
11 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 7/4/2024 in #djs-questions
My bot seems to not received the event "interactionCreate" from button sent in DM
I have the following partials enabled : partials: [Partials.Message, Partials.Reaction, Partials.GuildMember, Partials.ThreadMember, Partials.Channel]
(also you are only listening it to it once, idk if that was intentional)
Yes it was just for testing 😂 I changed it to "on" to avoid people saying "hey it's because you already received an event" (which is not the case)
11 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 7/4/2024 in #djs-questions
My bot seems to not received the event "interactionCreate" from button sent in DM
And intents are as follow :
intents: [
GatewayIntentBits.MessageContent,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.AutoModerationExecution
]
intents: [
GatewayIntentBits.MessageContent,
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.GuildMessageReactions,
GatewayIntentBits.GuildModeration,
GatewayIntentBits.GuildEmojisAndStickers,
GatewayIntentBits.GuildInvites,
GatewayIntentBits.GuildPresences,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildVoiceStates,
GatewayIntentBits.DirectMessages,
GatewayIntentBits.AutoModerationExecution
]
11 replies
DIAdiscord.js - Imagine an app
Created by !Delta! on 6/20/2024 in #djs-questions
Chanel Creation
It's the bot
22 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 6/8/2024 in #djs-questions
How to determine the number of messages from a user ?
Well, I suspected it, but thanks for confirming it :WumpsHeartyLove:
4 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 5/1/2024 in #djs-questions
Is there a way to get rate-limit data about an action (like update thread name) ?
Completely forgot to answer you, sorry 🙏 I hadn't seen the solution in its entirety and had stopped at the fact that an array of urls could be passed... Finally, I was able to use the function to do what I wanted 💪
12 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 5/1/2024 in #djs-questions
Is there a way to get rate-limit data about an action (like update thread name) ?
Indeed, I've seen this solution too. However, it doesn't suit me because it's only in a certain specific case that I wanted to check before making the API call 😭 But thanks you for your answers guys :WumpsHeartyLove:
12 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 5/1/2024 in #djs-questions
Is there a way to get rate-limit data about an action (like update thread name) ?
Oh thx, the answer was fast 😂 I will check the listener you gave me. But there is no function like <Client>.rest.isRateLimited(...) ?
12 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 4/1/2024 in #djs-questions
In autocomplete, how can I get the value of an option type "User" ?
Ok thanks 👍
4 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 12/27/2023 in #djs-questions
Does <GuildMessageManager>.fetch({ limit: x }) return a sorted Collection of message ?
Oh, thanks. That make sense 👍
3 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 12/7/2023 in #djs-questions
How to differentiate an defer interaction
I forgot to answer and you was right, I don't know why in my previous tests the result was different For real, I know: the problem was me and I surely made an error in my code 😂
10 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 12/7/2023 in #djs-questions
How to differentiate an defer interaction
Maybe it could be interesting to add two property: - updateDeferred - replyDeferred And change the deferred property to a getter equal to updateDeferred || replyDeferred Suggestion added in #Split "deferred" property in Interaction class in two, to better reflect previous actions in case there is no other way to do it
10 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 12/7/2023 in #djs-questions
How to differentiate an defer interaction
To be a little more precise for this:
but not after a deferReply
It's because, DiscordJS throw an error if you are using followUp without a full reply
10 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 12/7/2023 in #djs-questions
How to differentiate an defer interaction
If I use followUp the behavior after a deferUpdate is good (this is what I want) but not after a deferReply :/ I would like to keep using editReply() after a deferReply but I would like to use followUp() after deferUpdate. Here is a little piece of code that can help to understand the problem:
if (!interaction.isButton()) {
throw new Error("The interaction is not a button.")
}

try {
await InteractionService.buildActionFromInteraction(interaction)
.execute(client, interaction);
} catch (e: any) {
if (!interaction.replied && !interaction.deferred) {
return interaction.reply({ content: e.message });
} else if (interaction.replied) {
// I would like to fall here after a deferUpdate() also
return interaction.followUp({ content: e.message });
} else {
return interaction.editReply({ content: e.message });
}
}
if (!interaction.isButton()) {
throw new Error("The interaction is not a button.")
}

try {
await InteractionService.buildActionFromInteraction(interaction)
.execute(client, interaction);
} catch (e: any) {
if (!interaction.replied && !interaction.deferred) {
return interaction.reply({ content: e.message });
} else if (interaction.replied) {
// I would like to fall here after a deferUpdate() also
return interaction.followUp({ content: e.message });
} else {
return interaction.editReply({ content: e.message });
}
}
10 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 12/7/2023 in #djs-questions
How to differentiate an defer interaction
Ok, I will try to explain it : I listen to the "interactionCreate" event and call a function that depends on the ID of the button clicked. This function performs various tasks and may generate an error (unauthorized user, invalid parameter, etc.). This error is taken into account in the interaction creation event to send a response to the user, informing them of the system's status. But when the function throws an error and I catch it, I call editReply or reply depending on the deferred property to display the error message. There are three possible scenarios: - The function has never called a defer method: the behavior is correct. - The function called deferReply() before throwing an error: the behavior is correct. - The function called deferUpdate() before throwing an error: the initial message is updated with the error message, whereas I'd like to keep it and send another message containing the error. I can provide you a little piece of code if it can help you 👍
10 replies
DIAdiscord.js - Imagine an app
Created by Apokalypt on 11/27/2023 in #djs-questions
How to properly check if the channel fetch is one where threads can be created?
Oh thank you, until now I was using the "in" keyword but I think I will switch to the check with the type property WumpsHeartyLove Just to explain why I don't force the type even if I know it, it's juste because I don't trust data. I always perform controls to be sure that if the source of the data change later (user input) I don't have to make many changes since all controls are already there
5 replies
DIAdiscord.js - Imagine an app
Created by Baconburger998 on 3/28/2023 in #djs-questions
ThreadUpdate
inactiveThreads contains all archived threads fetched so the property <Thread>.archived will always be true for all threads fetched. Therefore, the rest of your code cannot be executed because as <Thread>.archived will always be true, !<Thread>.archived will always be false and you will never fall in the IF condition
8 replies