Stev
Stev
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by Stev on 6/22/2023 in #djs-questions
shardCreate/ShardingManager with shards: 'auto'?
Possibly a dumb question about sharding — I apologize if it is. I'm using shards: 'auto'. This is because for this specific bot, I'm only in around 40K servers and I only use around 2GB RAM. If I use a ShardingManager, and each process/worker has a MySQL connection pool using mysql2, the RAM usage increases drastically; I believe this is because it always keeps a connection open to improve performance... and MySQL reserves a lot of RAM for each connection. I end up maxing-out my VPS' 24GB. Is there an equivalent to ShardingManager.on('shardCreate', ...), or just a sharding manager in general, when using shards: 'auto'? Is there another approach you'd recommend to reduce resource usage than using shards: 'auto'? Cheers!
4 replies
DIAdiscord.js - Imagine an app
Created by Stev on 7/12/2022 in #djs-questions
Stumped with GuildAuditLogsEntry & TypeScript...
I'm kinda stumped with audit logs. I'm looking to get a few audit log entries of all recent actions of a user, and then create a simple embed. Here's an example of my problem:
const auditLogs = await guild.fetchAuditLogs({
before, limit: 100, user,
});

auditLogs.entries.forEach((entry) => {
switch(entry.action) {
case 'GUILD_UPDATE': // Type '"GUILD_UPDATE"' is not comparable to type '"ALL"'.
// ...
case 'MESSAGE_DELETE': // Type '"MESSAGE_DELETE"' is not comparable to type '"ALL"'.
// ...
}
});
const auditLogs = await guild.fetchAuditLogs({
before, limit: 100, user,
});

auditLogs.entries.forEach((entry) => {
switch(entry.action) {
case 'GUILD_UPDATE': // Type '"GUILD_UPDATE"' is not comparable to type '"ALL"'.
// ...
case 'MESSAGE_DELETE': // Type '"MESSAGE_DELETE"' is not comparable to type '"ALL"'.
// ...
}
});
What am I doing wrong?
3 replies
DIAdiscord.js - Imagine an app
Created by Stev on 6/22/2022 in #djs-questions
REST randomly forgets token set with setToken
I'm using @discordjs/rest and Fastify for HTTPS interactions. I'm initiating my REST client with:
const rest = new REST().setToken(DISCORD_TOKEN);
const rest = new REST().setToken(DISCORD_TOKEN);
The bot works fine for roughly a day before suddenly rejecting all requests with: Error: Expected token to be set for this request, but none was present https://github.com/discordjs/discord.js/blob/65d1879c0ae2d8d820323d0d835b1e5e3d071e57/packages/rest/src/lib/RequestManager.ts#L364 I can not, for the life of me, figure out why rest is consistently forgetting its token after roughly a day of operation. What am I missing?
14 replies