DiscordAPI Missing Access when trying to remove members from a thread

I’m working on a feature for my bot that allows server moderators to remove all users from a given thread who have not sent a single message in that thread in the past 30 days. I have everything working so far, up to generating a list of ThreadMember objects representing the users I want to kick. However, when I call the remove() function on these objects, I’m met with:

DiscordAPIError[50001]: Missing Access
     at SequentialHandler.runRequest (C:UsersXXXXXDesktopDV Discord BotDVDiscordBot1node_modules@discordjsrestdistindex.js:933:15)
     at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
     at async SequentialHandler.queueRequest (C:UsersXXXXXDesktopDV Discord BotDVDiscordBot1node_modules@discordjsrestdistindex.js:712:14)
     at async REST.request (C:UsersXXXXXDesktopDV Discord BotDVDiscordBot1node_modules@discordjsrestdistindex.js:1321:22)
     at async ThreadMemberManager.remove (C:UsersXXXXXDesktopDV Discord BotDVDiscordBot1node_modulesdiscord.jssrcmanagersThreadMemberManager.js:111:5)
     at async ThreadMember.remove (C:UsersXXXXXDesktopDV Discord BotDVDiscordBot1node_modulesdiscord.jssrcstructuresThreadMember.js:108:5) {        
   rawError: { message: 'Missing Access', code: 50001 },
   code: 50001,
   status: 403,
   method: 'DELETE',
   url: 'https://discord.com/api/v10/channels/1181506798549741688/thread-members/114958895482404868',
   requestBody: { files: undefined, json: undefined } 
}

Here is how I have the feature currently implemented, if it helps. getThreadMsgsAfterDate is a helper function that repeatedly runs fetch commands to grab as many messages as necessary, to get around the 100 messages cap per fetch.

let threadMems = await thread.members.fetch();
let time = new Date();
time.setDate(time.getDate() - 30);
msgs = await getThreadMsgsAfterDate(thread, time);
let idsFound = new Set();
msgs.forEach((obj) => {
    idsFound.add(obj.author);
});
console.log(`Found ${idsFound.size} unique users in ${msgs.length} messages`);
let notInMostRecent = [];
threadMems.each(mem => {
    if (!idsFound.has(mem.id)) {
        notInMostRecent.push(mem);
    }
});
console.log(`${notInMostRecent.length}/${threadMems.size} thread members were not found in the most recent messages`);
notInMostRecent.forEach((mem) => {
    mem.remove(`Removed from thread: "${thread.name}" for inactivity. Please rejoin if you wish to continue using it.`);
});

I can confirm that everything works exactly as intended up to the mem.remove() call, which gives me the error I posted above. Solutions I have attempted so far, based on google searching I have done:

  • 2FA is enabled on my (the bot owner’s) Discord account
  • The bot has been given the Manage Threads permission by the server owner
  • The bot uses the GuildMembers gateway intent (and several others – let me know if you want the complete list)

Any advice is appreciated on additional things I can try. It’s possible I may also have gotten one of the above attempts wrong as well – feel free to call me out if I have.

Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa Dịch vụ tổ chức sự kiện 5 sao Thông tin về chúng tôi Dịch vụ sinh nhật bé trai Dịch vụ sinh nhật bé gái Sự kiện trọn gói Các tiết mục giải trí Dịch vụ bổ trợ Tiệc cưới sang trọng Dịch vụ khai trương Tư vấn tổ chức sự kiện Hình ảnh sự kiện Cập nhật tin tức Liên hệ ngay Thuê chú hề chuyên nghiệp Tiệc tất niên cho công ty Trang trí tiệc cuối năm Tiệc tất niên độc đáo Sinh nhật bé Hải Đăng Sinh nhật đáng yêu bé Khánh Vân Sinh nhật sang trọng Bích Ngân Tiệc sinh nhật bé Thanh Trang Dịch vụ ông già Noel Xiếc thú vui nhộn Biểu diễn xiếc quay đĩa Dịch vụ tổ chức tiệc uy tín Khám phá dịch vụ của chúng tôi Tiệc sinh nhật cho bé trai Trang trí tiệc cho bé gái Gói sự kiện chuyên nghiệp Chương trình giải trí hấp dẫn Dịch vụ hỗ trợ sự kiện Trang trí tiệc cưới đẹp Khởi đầu thành công với khai trương Chuyên gia tư vấn sự kiện Xem ảnh các sự kiện đẹp Tin mới về sự kiện Kết nối với đội ngũ chuyên gia Chú hề vui nhộn cho tiệc sinh nhật Ý tưởng tiệc cuối năm Tất niên độc đáo Trang trí tiệc hiện đại Tổ chức sinh nhật cho Hải Đăng Sinh nhật độc quyền Khánh Vân Phong cách tiệc Bích Ngân Trang trí tiệc bé Thanh Trang Thuê dịch vụ ông già Noel chuyên nghiệp Xem xiếc khỉ đặc sắc Xiếc quay đĩa thú vị
Trang chủ Giới thiệu Sinh nhật bé trai Sinh nhật bé gái Tổ chức sự kiện Biểu diễn giải trí Dịch vụ khác Trang trí tiệc cưới Tổ chức khai trương Tư vấn dịch vụ Thư viện ảnh Tin tức - sự kiện Liên hệ Chú hề sinh nhật Trang trí YEAR END PARTY công ty Trang trí tất niên cuối năm Trang trí tất niên xu hướng mới nhất Trang trí sinh nhật bé trai Hải Đăng Trang trí sinh nhật bé Khánh Vân Trang trí sinh nhật Bích Ngân Trang trí sinh nhật bé Thanh Trang Thuê ông già Noel phát quà Biểu diễn xiếc khỉ Xiếc quay đĩa
Thiết kế website Thiết kế website Thiết kế website Cách kháng tài khoản quảng cáo Mua bán Fanpage Facebook Dịch vụ SEO Tổ chức sinh nhật