Search code examples
javascriptnode.jsdiscord.js

Discord.js - Removed channels are still visible on the client


I am currently writing a custom support ticket tool for a Discord with over 70k members, which spawns one category and three child-channels when a moderator investigates a ticket/report.

When the moderator is finished with the report, the created category and channels self-clean and get removed again. Though in some cases, these channels are still visible for the moderator even though they are, in fact, deleted.

I presume this is a caching issue on the client-side as every time the solution seems to be to reload the Discord client (ctrl+r). I am therefore wondering if there is something I can do code-wise that would avoid such issue.

Moderation happens around the clock and I can see this getting both annoying and looks like bad design for the customer if these channels keep on growing exponentially over-time.

A snippet of the self-cleaning function can be found below:

module.exports.cleanChannels = async (client, guild_id, channel) => {
    await client.guilds.cache.get(guild_id).channels.cache.get(channel.parentID).children.forEach(channel => channel.delete())
    await client.guilds.cache.get(guild_id).channels.cache.get(channel.parentID).delete()
}

Solution

  • I will mark this question as resolved. I am confident that we are looking at a client-side caching issue which is not solvable through the Discord bot.

    The only seemingly alternative is to take a wholly different approach. By using a continuous feed as opposed to spawning and deleting private channels, its possible to circumvent the caching issue presented above.