DiscordAPIError[0]: 405: Method Not Allowed

Hello, i have this code:
const { CommandInteraction, ChannelType, ButtonInteraction, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits, ModalBuilder, TextInputBuilder, TextInputStyle, ThreadMemberFlags } = require("discord.js");

module.exports = {
name: "threadMembersUpdate",

async execute(newMembers, oldMembers, thread) {

const threadName = `${thread.name}`

if (!threadName.includes("menu")) return

const threadMember = newMembers.firstKey()

try {
await thread.members.remove(threadMember);
} catch (err) {
console.log(err)
}

},
};
const { CommandInteraction, ChannelType, ButtonInteraction, EmbedBuilder, ActionRowBuilder, ButtonBuilder, ButtonStyle, PermissionFlagsBits, ModalBuilder, TextInputBuilder, TextInputStyle, ThreadMemberFlags } = require("discord.js");

module.exports = {
name: "threadMembersUpdate",

async execute(newMembers, oldMembers, thread) {

const threadName = `${thread.name}`

if (!threadName.includes("menu")) return

const threadMember = newMembers.firstKey()

try {
await thread.members.remove(threadMember);
} catch (err) {
console.log(err)
}

},
};
it works fine and removes users from thread, but every time i get error message:
DiscordAPIError[0]: 405: Method Not Allowed
at SequentialHandler.runRequest (D:\job\discord\Lumen\node_modules\@discordjs\rest\dist\index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (D:\job\discord\Lumen\node_modules\@discordjs\rest\dist\index.js:712:14)
at async REST.request (D:\job\discord\Lumen\node_modules\@discordjs\rest\dist\index.js:1321:22)
at async ThreadMemberManager.remove (D:\job\discord\Lumen\node_modules\discord.js\src\managers\ThreadMemberManager.js:111:5)
at async Object.execute (D:\job\discord\Lumen\Events\Tickets\ThreadRemove.js:14:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
rawError: { message: '405: Method Not Allowed', code: 0 },
code: 0,
status: 405,
method: 'DELETE',
url: 'https://discord.com/api/v10/channels/1098282953747996723/thread-members',
requestBody: { files: undefined, json: undefined }
}
DiscordAPIError[0]: 405: Method Not Allowed
at SequentialHandler.runRequest (D:\job\discord\Lumen\node_modules\@discordjs\rest\dist\index.js:933:15)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async SequentialHandler.queueRequest (D:\job\discord\Lumen\node_modules\@discordjs\rest\dist\index.js:712:14)
at async REST.request (D:\job\discord\Lumen\node_modules\@discordjs\rest\dist\index.js:1321:22)
at async ThreadMemberManager.remove (D:\job\discord\Lumen\node_modules\discord.js\src\managers\ThreadMemberManager.js:111:5)
at async Object.execute (D:\job\discord\Lumen\Events\Tickets\ThreadRemove.js:14:9)
Emitted 'error' event on Client instance at:
at emitUnhandledRejectionOrErr (node:events:394:10)
at process.processTicksAndRejections (node:internal/process/task_queues:84:21) {
rawError: { message: '405: Method Not Allowed', code: 0 },
code: 0,
status: 405,
method: 'DELETE',
url: 'https://discord.com/api/v10/channels/1098282953747996723/thread-members',
requestBody: { files: undefined, json: undefined }
}
Ty for help catKiss
2 Replies
d.js toolkit
d.js toolkit15mo ago
• What's your exact discord.js npm list discord.js and node node -v version? • Post the full error stack trace, not just the top part! • Show your code! • Explain what exactly your issue is. • Not a discord.js issue? Check out #useful-servers.
tenfy
tenfy15mo ago
I tried to mention two persons at the time and my bot removed only fist person because i want to make like menu in private thread When you click on button my bot creates private thead with embed and select menu. This menu belongs only to one person. I thought that some people can mention another users and they can brake my system. So I`m trying to avoid it by removing users from that thread. Ofc I can use DB, but i thought, that this solution for this problem will be easier. no, i think 5 minutes will be enough