Sharding is Required | Bot doesn't respond
I found out my bot stopped working and message content intents is enabled but greyed out on the Discord applications page. I updated discord.js then I'm having an error saying sharding is required. By setting the amount of shards to >= 2 the bot goes and connects however it doesn't respond.
112 Replies
• 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.How many guilds is your bot in?
@Danial
2510
that's probably my issue
Yes
I'm trying to implement shard.js but it's still not responding
could you help?
I've read it
still kind of confused
Show your code
@Danial
oh and more than 2 shards gives an error
I don't know much about sharding so I'll let someone else help you
I have gone to implement sharding but it's not actually reading stuff
@Danial how long will I have to wait in order to find someone which can help?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes I can be patient was just making sure that I don't have just silence sorry
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
that gonna make some difference?
well it seems to me like your current code won't log the
Lauching shard ...
messageit did
i guess that's fine then
also what do you mean by "the bot doesn't respond"? to what?
it's supposed to be reading server message
it doesn't
also
there's a command to give a verification code
it doesn't do anything rn
all that's going on with index.js is that that starts bot
can you send it?
bot.js would be nice to see as well
@d4isdavid
are you using v14? you should be using the
messageCreate
eventUnknown User•2y ago
Message Not Public
Sign In & Join Server To View
instead of what?
@d4isdavid
instead of
message
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I have that
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
what are partials doing?
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes
why do I have to parse intents to the program
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
do you mean pass intents?
yes
sorry
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I'm trying to go read intents with guild
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
sigh
what I meant's that I'm trying to read message intents via guild
not via dm
I know why intents have to be used
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
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:
just don't know why you have to pass it into the code
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
yes I just passed those in
still not reading
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
wait a second
there's a command which I had ran
it just sent 3 of them
because
there's 3 instances of the bot running
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
const client = new Discord.Client({ partials: [], shards: 'auto', shardCount: 5, intents: [Discord.GatewayIntentBits.Guilds, Discord.GatewayIntentBits.GuildMessages, Discord.GatewayIntentBits.MessageContent] }) // Allows me to recieve "uncached" (actually manually cached by me) message eventsshards
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
should this client code be put somewhere else?
shard.js is calling the index.js
which is calling bot.js
which contains the amount of shard
am I doing it wrong
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I think that I'm calling it wrong
i'm not sure that you should be using
shards
and shardCount
here, the guide certainly doesn'tok now it ran once
the problem is that my servers aren't loading
it doesn't look like it's reading
you mean your http server?
yes
the page loads
but
what the bot does is let you talk on discord with any client
that support html
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
I'm dealing with too much right now
that's probably why I can't correctlytalk
it's fine
basically I don't think guild are correctly being loaded on the bot after shard had to be implemented
because
the alternate client lets you pick from list of guild
currently it's empty
how do you get the list?
bot didn't respond until changed intents
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 guildsthis doesn't look like
processServer
to meI believe that it's having problem loading guild
it worked before
now it doesn't
before I had implemented shard the bot worked ok
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.jsinside bot.js or index.js?
i guess it's called shard.js
I don't know how to go start bot using that
bot.js has stuff in it
do I need to implement partials?
no, this isn't related to partials
"Cannot read properties of null (reading 'setActivity')"
I'm confused how I need to change thing
you are trying to use bot.js from shard.js, but there the Client would not be started
you should re-read this because it explains that separate processes are ran, and every process would have a different client
your main process would have a different client too
I'm confused
don't know what I have to change
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
should I put all the code in shard.js?
namely the client?
i don't think that's what i meant
you're telling me I can't call bot.js on shard.js?
yes
not like this at least
without sharding it would've been fine but with sharding you can't unfortunately
the code on discord.js documentation says that you call bot.js
there client's called
when using ShardingManager, yes
I'm confused what I need to do
sorry I didn't write this code I'm just maintaining
what do I need to substitute with the call of bot.js?
you have to change everything that uses the bot.js client inside of shard.js
change it to do?
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
sorry I thought that I sent that
you know what I can do to have it remedied?
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 shardswhat confuses me's that looking into example code each has a client
that doesn't change anything, each shard would still run that code on its own with a different
Client
instancewould moving the code over to be on shard.js help?
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 toodone
🤔
show the updated
shard.js
code pleasethank you for helping thus far 🙂
not very fun when my bot's in over 2500 discord and it break
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
I didn't know
really didn't see how many people had been adding the bot to their discord
you know why it became popular
?
michael mjd created a video on it
Unknown User•2y ago
Message Not Public
Sign In & Join Server To View
then lots of people started testing it
I know
@d4isdavid sorry to bother but you there?
sorry i gtg