我在这一点上真的无能为力,并试图查找我能想到的一切,我得到这个错误与我的代码:
ReferenceError: Cannot access 'options' before initialization
at file:///D:/node mods/agda.js/src/constants/Constants.js:4:45
Constants.js
import { options } from "../ws/WebSocketManager.js";
export const Constants = {
GATEWAY: `wss://gateway.discord.gg/?v=${options.gateway_version}&encoding=json`
}
WebSocketManager.js(只显示一个片段)
import WebSocket from 'ws';
import { Constants } from '../constants/Constants.js';
import { OPCodes } from '../constants/OPCodes.js';
import { Heartbeat, Identify } from '../constants/Payloads.js';
export const options = {
debugMode: true,
debugMode_payloads: true,
debugMode_connection: true,
debugMode_heartbeats: true,
useOS: 'linux',
intents: 513,
gateway_version: '9'
}
我已经用一种不同的方法修复了它。
对于那些可能需要它的人,
export const Gateway = {
URL: undefined,
VERSION: 9
}
Gateway.URL = `wss://gateway.discord.gg/?v=${Gateway.VERSION}&encoding=json`;