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?
3 Replies
d.js toolkit
d.js toolkit12mo 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
d.js docs
d.js docs12mo ago
Ratelimits are dynamically assigned by the API based on current load and may change at any point. - The scale from okay to API-spam is sliding and depends heavily on the action you are taking - Rainbow roles, clock and counter channels, and DM'ing advertisements to all members are all examples of things that are not okay
carabax
carabaxOP12mo ago
I read that 10 minutes is a valid value Isn't that right? But then why do many other developers use it... Okay... But in any case, I won't get any help? Solve:
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 => {
const strPlaying = String(playing).trim();
channelPlaying.setName(`🎮 Playing: ${strPlaying}`)
})
}, 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 => {
const strPlaying = String(playing).trim();
channelPlaying.setName(`🎮 Playing: ${strPlaying}`)
})
}, 10 * 60 * 1000);
Want results from more Discord servers?
Add your server