#Sharding is Required | Bot doesn't respond

70 messages · Page 1 of 1 (latest)

radiant hullBOT
#

• What's your exact discord.js npm list discord.js and node node -v version?
• Post the full error stack trace, not just the top part!
• Show your code!
• Explain what exactly your issue is.
• Not a discord.js issue? Check out #useful-servers.

barren fox
#

How many guilds is your bot in?

#

Yes

fiery shellBOT
barren fox
#

Show your code

#

I don't know much about sharding so I'll let someone else help you

sullen igloo
#

by waiting for someone that has the time. you just need to be patient. this is volunteer help and everyone has their own lives.

#

im not good with sharding either, but please at least have some patience

bold valve
#

notice that you try to listen to the shardCreate event only after actually creating the shards with spawn, the guide creates a listener first and then uses spawn

#

well it seems to me like your current code won't log the Lauching shard ... message

#

i guess that's fine then

#

also what do you mean by "the bot doesn't respond"? to what?

#

can you send it?

#

bot.js would be nice to see as well

#

are you using v14? you should be using the messageCreate event

sullen igloo
#

also, totalShards & shardList aren't valid options in v14, but there is shards and shardCount. partials also do not accept strings, especially SCREAMING_SNAKE. you'll need to use the Partials enum for that as well as changing your event name to messageCreate

bold valve
#

instead of message

sullen igloo
#

you also need the GuildMessages intent for getting guild messages. not sure if you're trying to listen to DMs or not

#

not in the code shown

#

are you asking what the purpose of them is?

fiery shellBOT
sullen igloo
#

not sure what you mean

bold valve
#

do you mean pass intents?

sullen igloo
#

they are required for using the gateway

#

and for listening to events

fiery shellBOT
sullen igloo
#

the guide covers this

#

that doesnt really make sense

#

okay so you need the Guilds, GuildMessages and MessageContent intent

fiery shellBOT
#

If you aren't getting content, embeds or attachments of a message, make sure you have the MessageContent intent enabled in the Developer Portal and provide it to your client:

const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
    intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildMessages, GatewayIntentBits.MessageContent]
});
sullen igloo
#

because that is required for using the gateway

#

and recieving event data

#

i basically just said that above

#

please show your updated code

#

why?

#

that doesnt cause responses to be sent multiple times

fiery shellBOT
sullen igloo
#

please look at this. i am not an expert at sharding

bold valve
#

i'm not sure that you should be using shards and shardCount here, the guide certainly doesn't

#

you mean your http server?

#

not sure what that means but you're trying to use bot.js from there as well, i don't know exactly if that would actually work depending on how you use it

#

it's fine

#

how do you get the list?

#

right but this doesn't really tell me anything, i need the line of code inside of the serverpage.processServer function which gets the list of guilds

#

this doesn't look like processServer to me

#

i don't see where you load guilds in this code

#

you might need to start using the manager variable inside of this code from now on instead of importing bot.js

#

i guess it's called shard.js

#

no, this isn't related to partials

#

you are trying to use bot.js from shard.js, but there the Client would not be started

bold valve
#

your main process would have a different client too

#

seems like you have to change a lot of things to implement sharding like this, mainly because you can't use bot.js from shard.js

#

i don't think that's what i meant

#

yes

#

not like this at least

#

without sharding it would've been fine but with sharding you can't unfortunately

#

when using ShardingManager, yes

#

you have to change everything that uses the bot.js client inside of shard.js

#

i'm not sure, it depends on what the code is doing, because currently your code assumes that there's a single instance of a client, when sharding creates multiple

#

ah i guess any functions here can't really be used correctly

#

every single shard runs index.js, meaning every shard has a different Client instance and a different bot.js instance

#

this means that every single variable inside of bot.js that you try to use inside of shard.js will be different from the shards

#

that doesn't change anything, each shard would still run that code on its own with a different Client instance

#

you need to move the cache parts of bot.js to shard.js

#

that's probably it? also every single part of code that uses bot.client inside of shard.js should be changed too

#

show the updated shard.js code please

sullen igloo
#

it would've been better to begin this process before reaching 2500 guilds, but that doesn't matter anymore

#

it's a requirement from discord. not really based on popularity

bold valve
#

sorry i gtg