carabax
carabax
DIAdiscord.js - Imagine an app
Created by carabax on 12/10/2023 in #djs-questions
TypeError: (data.name ?? channel.name).trim is not a function
Hello everyone! My idea is for the bot to record the number of players in the name of the voice channel every 10 minutes
const channelPlaying = client.channels.cache.get(...);

setInterval(function () {
...

function getPlaying() {
return fetch(APILink).then(res=>res.json()).then(jsonData=>jsonData.data[0].playing)
};
getPlaying().then(playing=>channelPlaying.setName(playing)
}, 10 * 60 * 1000);
const channelPlaying = client.channels.cache.get(...);

setInterval(function () {
...

function getPlaying() {
return fetch(APILink).then(res=>res.json()).then(jsonData=>jsonData.data[0].playing)
};
getPlaying().then(playing=>channelPlaying.setName(playing)
}, 10 * 60 * 1000);
... but this error appears
TypeError: (data.name ?? channel.name).trim is not a function
TypeError: (data.name ?? channel.name).trim is not a function
How can I fix it?
9 replies
DIAdiscord.js - Imagine an app
Created by carabax on 8/6/2022 in #djs-questions
TypeError Cannot read properties of undefined (reading 'id')
I get the error TypeError: Cannot read properties of undefined (reading 'tag') when I try to collect users, how do I fix it?
for (let i = 0; i < 10; i++) {
let user = await interaction.guild.members.fetch(array[i].id.split('_')[2]).tag;
content += `${i+1}. ${user} - ${array[i].data}\n`
};
for (let i = 0; i < 10; i++) {
let user = await interaction.guild.members.fetch(array[i].id.split('_')[2]).tag;
content += `${i+1}. ${user} - ${array[i].data}\n`
};
9 replies
DIAdiscord.js - Imagine an app
Created by carabax on 7/22/2022 in #djs-questions
TypeError db.all(...).filter is not a function
Yo, I am trying to make a leaderboard command, but this error TypeError: db.all(...).filter is not a function appears, how can I fix it?
let money = db.all().filter(data => data.ID.startsWith(`cash_`)).sort((a, b) => b.data - a.data);

money.length = 10;
var finalLb = "";
for (var i in money) {
if (money[i].data === null) money[i].data = 0
finalLb += `**${money.indexOf(money[i]) + 1}. ${client.users.cache.get(money[i].ID.split('_')[1]).tag}** - ${money[i].data}\n`;
};
let money = db.all().filter(data => data.ID.startsWith(`cash_`)).sort((a, b) => b.data - a.data);

money.length = 10;
var finalLb = "";
for (var i in money) {
if (money[i].data === null) money[i].data = 0
finalLb += `**${money.indexOf(money[i]) + 1}. ${client.users.cache.get(money[i].ID.split('_')[1]).tag}** - ${money[i].data}\n`;
};
6 replies