TerrorByte
TerrorByte
Explore posts from servers
DIAdiscord.js - Imagine an app
Created by TerrorByte on 11/25/2023 in #djs-questions
Receiving "ShardingReadyTimeout" even though ready event is firing
Hi there! I'm dealing with a strange problem and I'm not sure how to handle it. I'm receiving a ShardingReadyTimeout error, but the ready event is being fired before the error is occuring, so I therefore not sure how to handle it. I'm pretty sure it's being caused by my event handler, but I'm not sure why or how. Essentially, when the bot is actually created, it's firing a loadEvents method which is loading all the event files within my event directory, and attaching them to the client object. An event has a type of:
export type Event = {
name: keyof RestEvents | string
once: boolean
rest: boolean
execute: (...args: any[]) => void | Promise<void>
}
export type Event = {
name: keyof RestEvents | string
once: boolean
rest: boolean
execute: (...args: any[]) => void | Promise<void>
}
My index.ts, which is the sharding manager:
import { ShardingManager } from "discord.js"
import { getConfig } from "./modules/config"

const config = getConfig()
const manager = new ShardingManager("./bot.js", { totalShards: config.shards, token: `${config.token}` })

manager.on("shardCreate", shard => {
console.log(`Launched shard ${shard.id}`)
})

process.on("unhandledRejection", err => {
console.log((err as Error).stack, "error")
})

void manager.spawn()
import { ShardingManager } from "discord.js"
import { getConfig } from "./modules/config"

const config = getConfig()
const manager = new ShardingManager("./bot.js", { totalShards: config.shards, token: `${config.token}` })

manager.on("shardCreate", shard => {
console.log(`Launched shard ${shard.id}`)
})

process.on("unhandledRejection", err => {
console.log((err as Error).stack, "error")
})

void manager.spawn()
My client.ts, which is the actual bot code:
import { GatewayIntentBits, Partials } from "discord.js"
import { getConfig } from "./modules/config"
import CrystalClient from "./types/CrystalClient"

const config = getConfig()
const client = new CrystalClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
],
partials: [Partials.User, Partials.Message, Partials.GuildMember, Partials.ThreadMember],
})

void client.login(config.token)
import { GatewayIntentBits, Partials } from "discord.js"
import { getConfig } from "./modules/config"
import CrystalClient from "./types/CrystalClient"

const config = getConfig()
const client = new CrystalClient({
intents: [
GatewayIntentBits.Guilds,
GatewayIntentBits.GuildMembers,
GatewayIntentBits.GuildMessages,
GatewayIntentBits.MessageContent,
GatewayIntentBits.GuildVoiceStates,
],
partials: [Partials.User, Partials.Message, Partials.GuildMember, Partials.ThreadMember],
})

void client.login(config.token)
I'm extending the discord.js Client object to support some of my own functionality, so here is that file:
import { Client, type ClientOptions, Collection, type GuildBasedChannel } from "discord.js"
import { loadEvents } from "../modules/utils/eventHandler"
import { type Command } from "./Command"

export default class CrystalClient extends Client {
static commands: Collection<string, Command> // Not used yet, can be ignored
static events: Collection<string, (...args: any[]) => void> // Not used yet, can be ignored
static guilds: string[] // Not used yet, can be ignored
static channels: GuildBasedChannel[] = [] // Not used yet, can be ignored
private static client: CrystalClient

constructor(options: ClientOptions) {
super(options)
CrystalClient.client = this

CrystalClient.commands = new Collection() // Not used yet, can be ignored
CrystalClient.events = new Collection() // Not used yet, can be ignored

void loadEvents(CrystalClient.client)
}

static getClient(): CrystalClient {
return CrystalClient.client
}
}
import { Client, type ClientOptions, Collection, type GuildBasedChannel } from "discord.js"
import { loadEvents } from "../modules/utils/eventHandler"
import { type Command } from "./Command"

export default class CrystalClient extends Client {
static commands: Collection<string, Command> // Not used yet, can be ignored
static events: Collection<string, (...args: any[]) => void> // Not used yet, can be ignored
static guilds: string[] // Not used yet, can be ignored
static channels: GuildBasedChannel[] = [] // Not used yet, can be ignored
private static client: CrystalClient

constructor(options: ClientOptions) {
super(options)
CrystalClient.client = this

CrystalClient.commands = new Collection() // Not used yet, can be ignored
CrystalClient.events = new Collection() // Not used yet, can be ignored

void loadEvents(CrystalClient.client)
}

static getClient(): CrystalClient {
return CrystalClient.client
}
}
12 replies
AAdmincraft
Created by TerrorByte on 7/19/2023 in #questions
Garbage Collection is running, but it’s running extremely slow
No description
23 replies
AAdmincraft
Created by TerrorByte on 7/18/2023 in #questions
Continuous Purpur Thread Dumps, related to memory?
I keep having these weird thread dumps and OOM crashes on my server which are causing it to lock down entirely, requiring me to have to use the kill button in Pterodactyl. I have configured Aikars flags to limit the RAM usage of the server (I pay for 6 GB, Xmx is set to 5GB), and I've tried doing some profiling to no avail. All I know is that each thread dump referenced the UUID of one of our Admins who was just exploring. Any ideas? I'm at a loss, I really don't know what's going on at this point. I thought it may have been BlueMap because it's the most "resource intensive" thing I've done recently but I uninstalled that plugin and still have issues. I've also tried pregenerating chunks with Chunky, but I think that may be making it worse. Plugin List:
Paper Plugins: (2):
[23:30:57 INFO]: - eco, EconomyShopGUI
[23:30:57 INFO]: Bukkit Plugins: (45):
[23:30:57 INFO]: - BetterRTP, Chunky, ChunkyBorder, Citizens, CMILib, *CommandSpy, CoreProtect, Crystal-Extra-Flags, DecentHolograms, DimensionPause
[23:30:57 INFO]: DiscordSRV, DiscordSRV-Staff-Chat, EcoCrates, Essentials, EssentialsChat, EssentialsSpawn, ExtraContexts, FastAsyncWorldEdit, floodgate, Geyser-Spigot
[23:30:57 INFO]: GriefPrevention, InventoryRollbackPlus, ItemEditor, Jobs, LuckPerms, Maintenance, Multiverse-Core, Multiverse-Inventories, Multiverse-Portals, NBTAPI
[23:30:57 INFO]: PlaceholderAPI, PlayerWarps, PlugManX, ProtocolLib, QuickShop, sleep-most, spark, TAB, UltimateAutoRestart, Vault
[23:30:57 INFO]: ViaVersion, Votifier, VotingPlugin, WorldGuard, WorldGuardExtraFlags
Paper Plugins: (2):
[23:30:57 INFO]: - eco, EconomyShopGUI
[23:30:57 INFO]: Bukkit Plugins: (45):
[23:30:57 INFO]: - BetterRTP, Chunky, ChunkyBorder, Citizens, CMILib, *CommandSpy, CoreProtect, Crystal-Extra-Flags, DecentHolograms, DimensionPause
[23:30:57 INFO]: DiscordSRV, DiscordSRV-Staff-Chat, EcoCrates, Essentials, EssentialsChat, EssentialsSpawn, ExtraContexts, FastAsyncWorldEdit, floodgate, Geyser-Spigot
[23:30:57 INFO]: GriefPrevention, InventoryRollbackPlus, ItemEditor, Jobs, LuckPerms, Maintenance, Multiverse-Core, Multiverse-Inventories, Multiverse-Portals, NBTAPI
[23:30:57 INFO]: PlaceholderAPI, PlayerWarps, PlugManX, ProtocolLib, QuickShop, sleep-most, spark, TAB, UltimateAutoRestart, Vault
[23:30:57 INFO]: ViaVersion, Votifier, VotingPlugin, WorldGuard, WorldGuardExtraFlags
Output of /version:
[23:34:09 INFO]: Checking version, please wait...
[23:34:09 INFO]: Current: git-Purpur-2016 (MC: 1.20.1)*
* You are running the latest version
[23:34:09 INFO]: Checking version, please wait...
[23:34:09 INFO]: Current: git-Purpur-2016 (MC: 1.20.1)*
* You are running the latest version
And a snippet of the logs that keep being spit out has been attached as well.
52 replies