bomi
bomi
Explore posts from servers
SIASapphire - Imagine a framework
Created by bomi on 5/23/2023 in #sapphire-support
.loadAll() blocks all shards?
Okay, I have finally isolated my problem which I've opened multiple questions about. The problem is that
await client.stores.get('commands').loadAll();
await client.stores.get('commands').loadAll();
(my old bad way of getting all the pieces and reloading them in a loop does the same) Requirements for reproduction: - 20+ shards with ~15k guilds (not entirely sure that it's required actually) - active users using commands - run the code on all of them What happens: 1. About half of the shards complete the process within seconds. 2. All clients "freeze" for 10-20 seconds, the shards do not respond to any discord message or interaction. however the event loop does not seem to be blocked because independent functions still run. 3. All shards resume normal operation and the rest of the loadAlls finish. djs: 14.11.0 node: 16.13.1 sapphire/framework: 4.4.3
42 replies
SIASapphire - Imagine a framework
Created by bomi on 5/22/2023 in #discordjs-support
broadcastEval blocks all shards
Hello. I have a broadcastEval which calls a function on each shard. After running on about half of the shards, all shards "freeze" (They don't respond to any interactions or messages). After about 20-30 seconds, all shards resume normal operation. Then the shards that hadn't completed their function completes it, and the shards respond to all the interactions and messages that they got during the "freeze". This happened suddenly and to code that has been working well for many months. It did not happen when I updated, I hadn't updated for a while when it started happening. But I have updated to check if it would help. Should also be said it doesn't always happen. I think it does not happen right after shards have been restarted, but it happens say 90% of the time otherwise. I have not been able to reproduce this on a smaller bot. djs: 14.11.0 node: 16.13.1 sapphire/framework: 4.4.3 I've tried a lot of different evals and ways to call the function, right now it's:
let shardResult = await client.shard.broadcastEval(c => eval("global.reloadJuju()")) //eval-ing again because doing it directly threw an error
let shardResult = await client.shard.broadcastEval(c => eval("global.reloadJuju()")) //eval-ing again because doing it directly threw an error
async function reloadJuju() {
console.log("Starting Reloading on shard " + client.shard.ids[0])

await container.stores.get('commands').loadAll();

console.log("Done reloading commands on shard " + client.shard.ids[0])

let rpath = require.resolve('./vector.js');
delete require.cache[rpath]
rpath = require.resolve('./vector');
delete require.cache[rpath]
//deleting more cache here

console.log("reloaded on shard " + client.shard.ids + " at " + new Date().toLocaleString())

return true
}
global.reloadJuju = reloadJuju
async function reloadJuju() {
console.log("Starting Reloading on shard " + client.shard.ids[0])

await container.stores.get('commands').loadAll();

console.log("Done reloading commands on shard " + client.shard.ids[0])

let rpath = require.resolve('./vector.js');
delete require.cache[rpath]
rpath = require.resolve('./vector');
delete require.cache[rpath]
//deleting more cache here

console.log("reloaded on shard " + client.shard.ids + " at " + new Date().toLocaleString())

return true
}
global.reloadJuju = reloadJuju
I hope it's okay that I posted here, you've always been very good at figuring things out! if it's not ok, please tell me.
4 replies
SIASapphire - Imagine a framework
Created by bomi on 5/21/2023 in #sapphire-support
Somehow I got in an infinite loop
I have this old code that worked well for a long time, but somehow it now gets stuck in an infinite loop:
let cmdsrelo = await botclient.stores.get("commands")
console.log("gotten cmdsrelo on shard " + botclient.shard.ids[0])
for (let [key, value] of cmdsrelo) {
value.reload()
}
let cmdsrelo = await botclient.stores.get("commands")
console.log("gotten cmdsrelo on shard " + botclient.shard.ids[0])
for (let [key, value] of cmdsrelo) {
value.reload()
}
In some commands I have a console log such as "find all / Search loaded." Those are printed constantly but the "gotten cmdsrelo on shard"... Is seemingly not printed.
12 replies
SIASapphire - Imagine a framework
Created by bomi on 2/5/2023 in #sapphire-support
Very intense application command fetching
I'm using the new sapphire, v4.0.1 , with discord js v14.7.1 Suddenly, the the bot does an incredible amount of fetching of application commands, resulting in rate limit. {"timeToReset":1100,"limit":50,"method":"GET","hash":"Global(GET:/applications/:id/commands)","url":"https://discord.com/api/v10/applications/ID/commands?with_localizations=true","route":"/applications/:id/commands","majorParameter":"global","global":true} I have no clue why as I do not use any application commands. Neither any clue to what triggers it. It could be a discord.js problem of course but since I dont have any code at all relating to application commands, I think it's more likely sapphire?
59 replies
SIASapphire - Imagine a framework
Created by bomi on 1/22/2023 in #discordjs-support
Follow announcement channel
How do I follow an announcement channel? Like
let announcements = client.channels.fetch("id")
message.channel.follow(announcements)
let announcements = client.channels.fetch("id")
message.channel.follow(announcements)
Or is there no way to do this in discord.js so it has the be done some other way?
5 replies
SIASapphire - Imagine a framework
Created by bomi on 1/12/2023 in #discordjs-support
fetch channel returns undefined
Hello. I have this code, which worked before I believe:
let theChannel = await client.channels.fetch("1062775764853985321")
theChannel.send("blah")
let theChannel = await client.channels.fetch("1062775764853985321")
theChannel.send("blah")
Now it doesn't work, fetching the channel returns null without any error. {force: true} doesn't help Seems like discord has made some API changes?
10 replies
SIASapphire - Imagine a framework
Created by bomi on 12/29/2022 in #discordjs-support
Iterating over all server members OR iterating over people with x role
Hello. Thank you for always being so helpful and taking care of us. I'm having trouble iterating over but users and boosters. So my first approach was fetching all guild members, and iterating over that and checking if they are boosters, but fetching members times out. So I tried this simple fetch of all the role members:
let boosterRole = await message.channel.guild.roles.fetch("977927036523929600")

console.log(boosterRole)
let boosters = await boosterRole.members.map(m => m.user.id)
message.channel.send("Getting all users with the booster role... Done! " + boosters.length)
let boosterRole = await message.channel.guild.roles.fetch("977927036523929600")

console.log(boosterRole)
let boosters = await boosterRole.members.map(m => m.user.id)
message.channel.send("Getting all users with the booster role... Done! " + boosters.length)
This somewhat works, it gets only 4 users though (there is 23 boosters). All of the 4 users it gets are boosters though. Both the console log and the message says 4 members.
20 replies
SIASapphire - Imagine a framework
Created by bomi on 12/29/2022 in #sapphire-support
Encountered error on event listener CoreMessageParser f
Encountered error on event listener "CoreMessageParser" for event "preMessageParsed" at path "F:\JuyeonJS_chatMod\node_modules\@sapphire\framework\dist\listeners\command-handler\CoreMessageParser.js" Type
Error: me.isCommunicationDisabled is not a function
at CoreListener.canRunInChannel (F:\JuyeonJS_chatMod\node_modules\@sapphire\framework\dist\listeners\command-handler\CoreMessageParser.js:49:16)
Encountered error on event listener "CoreMessageParser" for event "preMessageParsed" at path "F:\JuyeonJS_chatMod\node_modules\@sapphire\framework\dist\listeners\command-handler\CoreMessageParser.js" Type
Error: me.isCommunicationDisabled is not a function
at CoreListener.canRunInChannel (F:\JuyeonJS_chatMod\node_modules\@sapphire\framework\dist\listeners\command-handler\CoreMessageParser.js:49:16)
Old working code started getting this error on any message...
20 replies
SIASapphire - Imagine a framework
Created by bomi on 12/9/2022 in #discordjs-support
Fetch membercount?
const theGuild = await botclient.guilds.fetch(channels[i].server, { force: false, allowUnknownGuild: true }).catch(() => null)
console.log(theGuild.memberCount)
const theGuild = await botclient.guilds.fetch(channels[i].server, { force: false, allowUnknownGuild: true }).catch(() => null)
console.log(theGuild.memberCount)
This returns undefined most of the time, the rest of the time it gives the membercount, any ideas why? Guessing when it's not loaded in the shard... But then how do I load it? .approximateMemberCount is the same.
8 replies