2

The part that I am struggling to change is: I am trying to change it from being "Playing Watching 50 members!" to just "watching 50 members!" but it still having an interval between the first status. I think the difference would be just to change "const activities = [" to "const something else = [" because the "activities" part automatically adds the "Playing" prefix and I would want it to be Watching or just nothing. Here is the entire code, I've also included it in the image:

client.login(process.env.token)
  const activities_list = [ 
      "Playing", 
      "Watching"
      ]; 
  client.on("ready", async() => {
    console.log("Bot is truly online!")
    let servers = await client.guilds.cache.size
    let servercount = await client.guilds.cache.reduce((a,b) => a+b.memberCount, 0 )

  const activities = [
    `MARK'S NEW VIDEO | ${servers} servers`,
    `Watching ${servercount} members!
  ]
  setInterval(()=>{
    const status = activities[Math.floor(Math.random()*activities.length)]
    client.user.setPresence({ activities : [{name : `${status}`}]})
  
  }, 3000)
  
})

enter image description here

enter image description here

Ethan
  • 881
  • 8
  • 14
  • 26
Mark Brand
  • 23
  • 4

1 Answers1

1

When you set the status to Watching ${servercount} members! that will be the whole message for the status. To change it to another kind (playing, online etc) in the .setPresence to { type: activityType }. For example this is what the code would looks like.

const activities = [
  [`PLAYING`, `MARK'S NEW VIDEO | ${servers} servers`],
  [`WATCHING`, `${servercount} members!`]
]
setInterval(()=>{
  const randomIndex = Math.floor(Math.random()*activities.length)
  const activityType = activities[randomIndex][0]
  const activity = activities[randomIndex][1]

  client.user.setPresence({ activities: [{ name: activity, type: activityType }]});
}, 3000) 
Ethan
  • 881
  • 8
  • 14
  • 26
  • I see. That makes much more sense than what I had, which helped me since I am new to Javascript. However, doing this method resulted in the need to define `randomIndex` and because I don't know the exact role of `randomIndex` in this case, I didn't know how to define it. But either way this was pretty impressive. – Mark Brand Oct 05 '22 at 23:46
  • 1
    My bad it’s the wrong var name since that segment of code from a project of mine. I changed it to the right var. – Ethan Oct 06 '22 at 00:22
  • Hmmm, that fixes the syntax error I had in the beginning, but with this one, the bot shows no status at all and there isn't even a syntax error message or anything in the replit. Here is an image of my view: https://cdn.discordapp.com/attachments/1024770893274161183/1027386607566848100/unknown.png – Mark Brand Oct 06 '22 at 01:08
  • 1
    hmm... I'm still trying to figure out whats wrong. – Ethan Oct 06 '22 at 13:49
  • 1
    @MarkBrand I realized that the status type may need to be in caps. Can you try now? – Ethan Oct 07 '22 at 21:06
  • IT WORKED! Thank you so much for your help, this also helped me learn a bit. I'm glad the status shows what I was looking for for a long time. – Mark Brand Oct 08 '22 at 12:25