Mirai-Miki
DIAdiscord.js - Imagine an app
•Created by Mirai-Miki on 12/21/2023 in #djs-questions
Typescript issues
I just recently switched to using typescript and I am having a little trouble when trying to get options from CommandInteractions. interaction.options is a CommandInteractionOptionResolver but when i try to use it it gives me a type error saying that the type is actually an
Omit<CommandInteractionOptionResolver<CacheType>, "getMessage" | "getFocused" | "getMentionable" | "getRole" | "getAttachment" | ... 6 more ... | "getSubcommand">
which would be fine except the things it is emiting are the options I am trying to get. Eg options.getBoolean() is emitted but it is added as one of the command options.
Am I missing something here or do I just have to do work arounds like explicitly telling the compiler that interaction.options as CommandInteractionOptionResolver
so I can actually use my options?7 replies
DIAdiscord.js - Imagine an app
•Created by Mirai-Miki on 4/4/2023 in #djs-questions
DiscordAPIError[50001]: Missing Access. In private threads
I am trying to create a MessageComponentCollector for an interaction Command. It works fine in private channels but in threads started inside those channels the interaction.channel property is null and trying to fetch the channel leads to a DiscordAPIError for missing access.
While I would say that the bot just cannot access that channel the interaction command works fine and in discord.js v13 fetching the threads also worked, as the bots were previously working fine in those threads before I updated to v14. So I am thinking it might be a bug in Discord.js v14
You can reproduce this by starting a private channel then creating a thread (private or not, doesn't matter) from this channel. Then trying to fetch that thread while using an interaction command from inside the thread.
interaction.client.channels.fetch(interaction.channelId);
Stack Trace
Discord.js v14.9.0
Node v18.15.02 replies
DIAdiscord.js - Imagine an app
•Created by Mirai-Miki on 12/8/2022 in #djs-questions
guildMemberRemove uncached members
So I am capturing guildMemberRemove events and I have the GuildMember and User partials selected.
When the member leaves the guild I have to check if the member had certain roles and if they did, update my database to say they are no longer have those rights.
The problem is if the member is not cached when the event fires, calling member.fetch() will return an Uknown Member APIError. I assume this is because the member no longer exists so you cannot fetch them.
What would be the best way to handle checking the roles of uncached members after they leave so i can update my database?
7 replies