Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Non-Sharded Functions#10573

Unanswered
Legends-of-NGDB asked this question inQ&A
Oct 22, 2024· 2 comments· 1 reply
Discussion options

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?

You must be logged in to vote

Replies: 2 comments 1 reply

Comment options

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){}}
You must be logged in to vote
0 replies

This comment was marked as spam.

@Qjuh
Comment options

QjuhJan 3, 2025
Collaborator

Don’t post AI responses. Like most AI responses it‘s long, convoluted and - most importantly - wrong.

Sign up for freeto join this conversation on GitHub. Already have an account?Sign in to comment
Category
Q&A
Labels
None yet
3 participants
@Legends-of-NGDB@Qjuh@RlxChap2

[8]ページ先頭

©2009-2025 Movatter.jp