Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 7 additions & 0 deletions .env copy
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
RPP_DISCORD_TOKEN=
RPP_DISCORD_CLIENT_ID=
RPP_RECONNECT_INTERVAL=15000
RPP_LOG_CALL_STACK=false
RPP_POLLING_INTERVAL=10000
RPP_LANGUAGE=en

2 changes: 1 addition & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -4,4 +4,4 @@ instances
credentials
maps
logs
temp
temp
55 changes: 54 additions & 1 deletion index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,8 @@
*/

const Discord = require('discord.js');
require('dotenv').config();

const Fs = require('fs');
const Path = require('path');

Expand All @@ -35,7 +37,58 @@ const client = new DiscordBot({
Discord.GatewayIntentBits.GuildVoiceStates],
retryLimit: 2,
restRequestTimeout: 60000,
disableEveryone: false
disableEveryone: false,
// Memory optimization options
makeCache: Discord.Options.cacheWithLimits({
MessageManager: 50, // Limit message cache to 50 messages per channel
ChannelManager: 200, // Limit channel cache
GuildMemberManager: 100, // Limit member cache per guild
UserManager: 200, // Limit user cache
PresenceManager: 0, // Disable presence cache (not needed)
StageInstanceManager: 0, // Disable stage instance cache
VoiceStateManager: 50, // Limit voice state cache
ThreadManager: 25, // Limit thread cache
ReactionManager: 25, // Limit reaction cache
ReactionUserManager: 0, // Disable reaction user cache
ApplicationCommandManager: 0, // Disable application command cache
BaseGuildEmojiManager: 0, // Disable emoji cache
GuildEmojiManager: 0, // Disable guild emoji cache
GuildStickerManager: 0, // Disable sticker cache
GuildScheduledEventManager: 0, // Disable scheduled event cache
GuildInviteManager: 0, // Disable invite cache
GuildBanManager: 0, // Disable ban cache
AutoModerationRuleManager: 0, // Disable auto moderation cache
ThreadMemberManager: 0 // Disable thread member cache
}),
// Sweep options for automatic cache cleanup
sweepers: {
messages: {
interval: 300, // Sweep every 5 minutes
lifetime: 1800 // Remove messages older than 30 minutes
},
users: {
interval: 600, // Sweep every 10 minutes
filter: () => (user: any) => user.bot && user.id !== client.user.id // Keep only non-bot users and self
},
guildMembers: {
interval: 900, // Sweep every 15 minutes
filter: () => (member: any) => member.id !== client.user.id // Keep only self
},
threads: {
interval: 3600, // Sweep every hour
lifetime: 14400 // Remove threads older than 4 hours
}
},
// Additional memory optimizations
allowedMentions: {
parse: ['users', 'roles'], // Only parse user and role mentions
repliedUser: false // Don't mention replied user by default
},
// Reduce WebSocket options for memory efficiency
ws: {
compress: true, // Enable compression to reduce bandwidth
large_threshold: 50 // Reduce large guild threshold
}
});

client.build();
Expand Down
Loading