membercount as activity precence

I want to take the Member count and put in inside my precence so people can see it in the activity my current code:
module.exports = {
name: 'ready',
once: true,
async execute(client) {

setInterval(() => {
let membersCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)

}, 1000 * 60 * 5);
const options = [
{
type: ActivityType.Playing,
text: `mit [${membersCount} usern]`,
status: "online"
}
];
await client.user.setPrecence({
activities: [{
name: [options].text,
type: [options].type
},
],
status: [options].status
}).catch(console.error);
}
}
module.exports = {
name: 'ready',
once: true,
async execute(client) {

setInterval(() => {
let membersCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)

}, 1000 * 60 * 5);
const options = [
{
type: ActivityType.Playing,
text: `mit [${membersCount} usern]`,
status: "online"
}
];
await client.user.setPrecence({
activities: [{
name: [options].text,
type: [options].type
},
],
status: [options].status
}).catch(console.error);
}
}
Error: membersCount is not defined- I'm not even sure if this whole code is right..
13 Replies
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
조아오
조아오3y ago
Your error does not reflect your code, membersCount isn't a thing, the memberCount in your code is I would also set a bigger interval
Knabbiii ♡ ˚₊‧⁺˖
i tried this
module.exports = {
name: 'ready',
once: true,
async execute(client) {

setInterval(async () => {
let membersCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options = [
{
type: ActivityType.Playing,
text: `mit [${membersCount} usern]`,
status: "online"
}
];
await client.user.setPrecence({
activities: [{
name: [options].text,
type: [options].type
},
],
status: [options].status
}).catch(console.error);
}, 1000 * 60 * 10);


}
}
module.exports = {
name: 'ready',
once: true,
async execute(client) {

setInterval(async () => {
let membersCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options = [
{
type: ActivityType.Playing,
text: `mit [${membersCount} usern]`,
status: "online"
}
];
await client.user.setPrecence({
activities: [{
name: [options].text,
type: [options].type
},
],
status: [options].status
}).catch(console.error);
}, 1000 * 60 * 10);


}
}
still not showin i feel like im doing something hella wrong
d.js docs
d.js docs3y ago
guide Additional Information: Changes and deletions - ClientUser read more
조아오
조아오3y ago
Nop This is for v13, my bad It's a Typo lol
d.js docs
d.js docs3y ago
method ClientUser#setPresence() Sets the full presence of the client user.
조아오
조아오3y ago
.setPresence not .setPrecence
Knabbiii ♡ ˚₊‧⁺˖
not the solution, sadly or do I have to wait this interval after starting?
조아오
조아오3y ago
You have to meguFace can assign the code inside the interval to its own function And call it before and inside the interval
Knabbiii ♡ ˚₊‧⁺˖
I did
const memberCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options = [
{
type: ActivityType.Playing,
text: `mit ${memberCount} usern`,
status: "online"
}
];
await client.user.setPresence({
activities: [{
name: [options].text,
type: [options].type
},
],
status: [options].status
}).catch(console.error);
const memberCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options = [
{
type: ActivityType.Playing,
text: `mit ${memberCount} usern`,
status: "online"
}
];
await client.user.setPresence({
activities: [{
name: [options].text,
type: [options].type
},
],
status: [options].status
}).catch(console.error);
before the interval And i get TypeError [InvalidType]: Supplied activities[0].name is not a string. I think its because its an Array in an Array
조아오
조아오3y ago
Why options is an array anyways? Couldn't just be an object?
Knabbiii ♡ ˚₊‧⁺˖
const memberCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options =
{
type: ActivityType.Playing,
text: `mit ${memberCount} usern`,
status: "online"
}
await client.user.setPresence({
activities: {
name: [options].text,
type: [options].type
},
status: [options].status
})
const memberCount = client.guilds.cache.map(guild => guild.memberCount).reduce((a, b) => a + b, 0)
const options =
{
type: ActivityType.Playing,
text: `mit ${memberCount} usern`,
status: "online"
}
await client.user.setPresence({
activities: {
name: [options].text,
type: [options].type
},
status: [options].status
})
No error anymore... but no activiety still take text from options You have a fix? Can you help me fix it then? so i delete the options const and just write in after the ":"? sry i mean ":" bro idk truly i forgot it tell me nice do i even need it i think with those answers, i just get to know what i know so or so I just started blindly like many other programmers did Dont tell me non stop that i dont know javascript basic. This isnt helping a beginner at all
Unknown User
Unknown User3y ago
Message Not Public
Sign In & Join Server To View
Want results from more Discord servers?
Add your server