Mirai-Miki
Mirai-Miki
DIAdiscord.js - Imagine a boo! 👻
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 anOmit<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 a boo! 👻
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
DiscordAPIError[50001]: Missing Access
at SequentialHandler.runRequest (/home/bot/Realm-of-Darkness-Bot/node_modules/@discordjs/rest/dist/index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (/home/bot/Realm-of-Darkness-Bot/node_modules/@discordjs/rest/dist/index.js:712:14)
at async REST.request (/home/bot/Realm-of-Darkness-Bot/node_modules/@discordjs/rest/dist/index.js:1321:22)
at async ChannelManager.fetch (/home/bot/Realm-of-Darkness-Bot/node_modules/discord.js/src/managers/ChannelManager.js:123:18)
at async handleRerollPress (/home/bot/Realm-of-Darkness-Bot/modules/dice/5th/handleRerollPress.js:16:18)
at async vtmRoll (/home/bot/Realm-of-Darkness-Bot/modules/dice/5th/vtmRoll.js:18:3)
at async Object.execute (/home/bot/Realm-of-Darkness-Bot/commands/5th/vtmDice.js:18:16)
at async Object.execute (/home/bot/Realm-of-Darkness-Bot/events/interactionCreate.js:22:31)
DiscordAPIError[50001]: Missing Access
at SequentialHandler.runRequest (/home/bot/Realm-of-Darkness-Bot/node_modules/@discordjs/rest/dist/index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (/home/bot/Realm-of-Darkness-Bot/node_modules/@discordjs/rest/dist/index.js:712:14)
at async REST.request (/home/bot/Realm-of-Darkness-Bot/node_modules/@discordjs/rest/dist/index.js:1321:22)
at async ChannelManager.fetch (/home/bot/Realm-of-Darkness-Bot/node_modules/discord.js/src/managers/ChannelManager.js:123:18)
at async handleRerollPress (/home/bot/Realm-of-Darkness-Bot/modules/dice/5th/handleRerollPress.js:16:18)
at async vtmRoll (/home/bot/Realm-of-Darkness-Bot/modules/dice/5th/vtmRoll.js:18:3)
at async Object.execute (/home/bot/Realm-of-Darkness-Bot/commands/5th/vtmDice.js:18:16)
at async Object.execute (/home/bot/Realm-of-Darkness-Bot/events/interactionCreate.js:22:31)
Discord.js v14.9.0 Node v18.15.0
2 replies
DIAdiscord.js - Imagine a boo! 👻
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