The problem with counting users in voice channels

The problem with counting users in voice channels, the input to the channel works fine, but the output remains the highest value and the number does not decrease.
const bannerUpdate = async () => {
const totalMembers = guild.memberCount;
console.log(`Общее количество участников на сервере: ${totalMembers}`);

await guild.members.fetch();

let voiceMembers = guild.voiceStates.cache.filter(voiceState => !voiceState.member.user.bot).size;
console.log(`Количество участников в голосовых каналах: ${voiceMembers}`);

const banner = canvas.createCanvas(1920, 1080);
const context = banner.getContext('2d');

const background = await canvas.loadImage(path.join(__dirname, 'background.png'));
context.drawImage(background, 0, 0, banner.width, banner.height);

context.fillStyle = 'white';
context.shadowColor = 'pink';
context.textSpacing = 100;
context.shadowBlur = 120;
context.shadowOffsetX = 0;
context.shadowOffsetY = 0;
registerFont(require("@canvas-fonts/comic-sans-ms"), { family: "Comic Sans MS" });
context.font = '145px "Comic Sans MS"';
context.textAlign = 'center';
context.fillText(`${totalMembers}`, 1382.5, 375);
context.fillText(`${voiceMembers}`, 1382.5, 755);

context.globalCompositeOperation = 'lighter';
context.strokeStyle = 'pink';
context.lineWidth = 10;
context.textSpacing = 100;
context.strokeText(`${totalMembers}`, 1382.5, 375);
context.strokeText(`${voiceMembers}`, 1382.5, 755);

context.textSpacing = 100;

const bannerImage = banner.toBuffer()
guild.setBanner(bannerImage)
.then(updated => console.log(`Updated the banner of ${updated.name}`))
.catch(console.error);
};

bannerUpdate();

setInterval(bannerUpdate, 1 * 60 * 1000);
const bannerUpdate = async () => {
const totalMembers = guild.memberCount;
console.log(`Общее количество участников на сервере: ${totalMembers}`);

await guild.members.fetch();

let voiceMembers = guild.voiceStates.cache.filter(voiceState => !voiceState.member.user.bot).size;
console.log(`Количество участников в голосовых каналах: ${voiceMembers}`);

const banner = canvas.createCanvas(1920, 1080);
const context = banner.getContext('2d');

const background = await canvas.loadImage(path.join(__dirname, 'background.png'));
context.drawImage(background, 0, 0, banner.width, banner.height);

context.fillStyle = 'white';
context.shadowColor = 'pink';
context.textSpacing = 100;
context.shadowBlur = 120;
context.shadowOffsetX = 0;
context.shadowOffsetY = 0;
registerFont(require("@canvas-fonts/comic-sans-ms"), { family: "Comic Sans MS" });
context.font = '145px "Comic Sans MS"';
context.textAlign = 'center';
context.fillText(`${totalMembers}`, 1382.5, 375);
context.fillText(`${voiceMembers}`, 1382.5, 755);

context.globalCompositeOperation = 'lighter';
context.strokeStyle = 'pink';
context.lineWidth = 10;
context.textSpacing = 100;
context.strokeText(`${totalMembers}`, 1382.5, 375);
context.strokeText(`${voiceMembers}`, 1382.5, 755);

context.textSpacing = 100;

const bannerImage = banner.toBuffer()
guild.setBanner(bannerImage)
.then(updated => console.log(`Updated the banner of ${updated.name}`))
.catch(console.error);
};

bannerUpdate();

setInterval(bannerUpdate, 1 * 60 * 1000);
4 Replies
d.js toolkit
d.js toolkit11mo ago
- What's your exact discord.js npm list discord.js and node node -v version? - Not a discord.js issue? Check out #other-js-ts. - Consider reading #how-to-get-help to improve your question! - Explain what exactly your issue is. - Post the full error stack trace, not just the top part! - Show your code! - Issue solved? Press the button! - Marked as resolved by OP
/|ĶÎŦÃŖŮ|\
/|ĶÎŦÃŖŮ|\OP11mo ago
I tried both saving values to a file and clearing the cache, using the database and nothing helped.
Unknown User
Unknown User11mo ago
Message Not Public
Sign In & Join Server To View
/|ĶÎŦÃŖŮ|\
/|ĶÎŦÃŖŮ|\OP11mo ago
No description
Want results from more Discord servers?
Add your server