Uh oh!
There was an error while loading.Please reload this page.
- Notifications
You must be signed in to change notification settings - Fork4.1k
Non-Sharded Functions#10573
-
Hello again. I think I have discovered in my other discussion why I'm sometimes hitting the rate limit for broadcastEval, but not totally. mongoose.connect(mongoURL||'',{}).then(()=>{setTimeout(()=>{setInterval(()=>{checkUpdates(client)},130_000);// setTimeout(() => {// setInterval(() => { twitch(client); }, 80_000);// setTimeout(() => {// setInterval(() => { antibot(client); }, 30_000);setTimeout(()=>{setInterval(()=>{checkGiveaway(client);},5000);setTimeout(()=>{setInterval(()=>{checkAIChannels()},10_000);},20000);},20000);//}, 20000);// }, 20000);},20000);}) These are function that I call for broadcastEval() and they are happening in my bot.js soevery shard is calling them. This is very unnecessary as the function to run on its own shard. I haven't reached 2500 guilds yet, but is there a work around without a discord.js error about sharding? I was thinking something like this: const{ Client, GatewayIntentBits, Partials, ShardingManager}=require('discord.js');require('dotenv').config();//this is just another client, don't concern yourself with this oneconstscrapper=newClient({intents:[GatewayIntentBits.Guilds,GatewayIntentBits.GuildMembers,GatewayIntentBits.GuildMessages,],partials:[Partials.User,Partials.GuildMember],});scrapper.login(process.env.scrapper)constmanager=newShardingManager('./bot.js',{token:process.env.token,shards:'auto'});manager.on('shardCreate',shard=>console.log(`Launched shard${shard.id}`));manager.spawn();constngdb=newClient({intents:[//GatewayIntentBits.GuildPresences,GatewayIntentBits.Guilds,GatewayIntentBits.GuildMembers,GatewayIntentBits.GuildMessages,GatewayIntentBits.GuildMessageReactions,GatewayIntentBits.MessageContent,],partials:[Partials.Channel,Partials.User,Partials.Message,Partials.Reaction,Partials.GuildMember],});ngdb.login(process.env.token)//import the function here and pass client as "ngdb"module.exports={ scrapper, manager, ndgb} Would this example work? |
BetaWas this translation helpful?Give feedback.
All reactions
Replies: 2 comments 1 reply
-
My reaction event also is running on shards when I'm using broadcastEval. This probably is why I'm encountering it constngdb=require(`./../@ngdb`);constreactions=require(`./../Schemas/react.js`);module.exports=async(client,reaction,user)=>{console.log(reaction.message.guild)if(user.bot||!reaction.message.guildId)return;ngdb.AddBuilder(client,reaction,user);returnreactionRole(client,reaction,user);}asyncfunctionreactionRole(client,reaction,user){try{letemoji;if(reaction.emoji.id){// Custom emojiemoji=`<:${reaction.emoji.name}:${reaction.emoji.id}>`;}else{// Unicode emojiemoji=reaction.emoji.name;}constdata=awaitreactions.findOne({Guild:reaction.message.guildId,Message:reaction.message.id,Emoji:emoji});if(!data)return;constguildEval=reaction.message.guildId;constshardId=Discord.ShardClientUtil.shardIdForGuildId(guildEval,client.shard.count);client.shard.broadcastEval(async(c,{ guildEval})=>{if(c.guilds.cache.has(guildEval)){constguild=awaitc.guilds.fetch(guildEval)constmember=awaitguild.members.cache.get(user.id);try{awaitmember.roles.add(data.Role);}catch(e){return;}}},{context:{ guildEval},shard:shardId})}catch(e){}} |
BetaWas this translation helpful?Give feedback.
All reactions
This comment was marked as spam.
This comment was marked as spam.
-
Don’t post AI responses. Like most AI responses it‘s long, convoluted and - most importantly - wrong. |
BetaWas this translation helpful?Give feedback.