#Ehm?

37 messages · Page 1 of 1 (latest)

loud shellBOT
#
  • What's your exact discord.js npm list discord.js and node node -v version?
  • Not a discord.js issue? Check out #1081585952654360687.
  • 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
young plinth
#

you have 11 error listeners somewhere

#

ah

#

youd want to update djs first of all

frail glen
#

That’s usually happening if you have a setInterval trying to setPresence on a not-logged in client

limpid igloo
limpid igloo
frail glen
limpid igloo
frail glen
#

Don’t do that on an interval and instead do it in guildCreate/guildDelete event when that number actually changes (and on shardReady initially and after each reconnect )

limpid igloo
#

yeah not in the sharding phase yet XD
so just client.user.setActivity in every guildAdd call?

#

Also do you recon its smart to save the number in a DB so its easier to display it on a website? Or am I just supposed to call to discords API, totally offtopic here iknow, just popped in my head

frail glen
#

You have one shard. So that event is exactly what you want, because it emits on every (re)connect, not just the initial one

limpid igloo
frail glen
limpid igloo
frail glen
#

Why? I‘d recommend having an API on your bot and query that from your website‘s server. Or run the server from the bot‘s process if that’s feasible

limpid igloo
#

I mean... the bot is on the same VPS anyway so that wouldnt hurt.. how about getting guild channels tho? or is that someht i can dowithout bot tokens

frail glen
#

Same answer

limpid igloo
#

Well, if that's the case it's much safer, thanks!

limpid igloo
# frail glen Don’t do that on an interval and instead do it in guildCreate/guildDelete event ...

Hi,

shardReady.js

module.exports = {
    name: 'shardReady',
    async execute(client) {
       await client.user.setActivity(`over ${client.guilds.cache.size} servers | /help`, { type: ActivityType.Watching });
    }
}```


shardResume.js
```js
module.exports = {
    name: 'shardResume',
    async execute(client) {
       await client.user.setActivity(`over ${client.guilds.cache.size} servers | /help`, { type: ActivityType.Watching });
    }
}

like this i'd assume correct?

#

yeah this is not working
node:events:492
throw er; // Unhandled 'error' event
^

TypeError: Cannot read properties of undefined (reading 'setActivity')

frail glen
#

shardReady emits with an id (number), not the client

limpid igloo
#

so, id .setActivety

#

that does not seem right either

frail glen
#

That event should be added directly in your file where you define client. Because it doesn’t emit with anything you can get the client from

limpid igloo
frail glen
#

No? Where did you get manager from what I said

limpid igloo
#

still returning 0, and this is the index

frail glen
#

Well, the first shard has id 0, so that’s expected

#

But you have the client variable there to call setActivity on

limpid igloo
#

and then id sassume shardResume is working just fine?

frail glen
#

You don’t need to do that on shardResume at all

limpid igloo
#

ah since its on shardStart already correct?

frail glen
#

shardReady but yes

limpid igloo
#
const { ActivityType } = require("discord.js");

module.exports = {
    name: 'guildCreate',
    async execute(client) {
       await client.user.setActivity(`over ${client.guilds.cache.size} servers | /help`, { type: ActivityType.Watching });
    }
}

So should this be in the main too