1
votes

Got some caching issues with discord.js v12 and im trying to figure out how to get around this issue to be honest because it's limiting the functionality i wanna do.

So i did this mute function and i wanna check if they got the muted role, the issue here is it caches, and keeps giving the same result until i restart the bot.

The code looks like this

var discordMember = await message.mentions.members.first() || await message.guild.members.fetch(args[0]);
var role = await message.guild.roles.cache.find(role => role.name == channelName.name + "-mute");
var hasRole = await discordMember.roles.cache.has(role.id);

The main issue here is:

var hasRole = await discordMember.roles.cache.has(role.id);

it keeps returning either true or false, depending on when i restart the bot, how do i get around the caching issue??

1
Maybe try var hasRole = await discordMember.roles.cache.get(role.id);WideIrenaKan1
Same issue sadlyBenzon

1 Answers

0
votes

They way to handle the cache issue was to actually just use

await message.guild.members.fetch({user: args[0], force: true})