问题描述
此时我真的一无所知,并已尝试查找我能想到的所有内容,但我的代码出现此错误:
ReferenceError: Cannot access 'options' before initialization
at file:///D:/node mods/agda.js/src/constants/Constants.js:4:45
常量.js
import { options } from "../ws/WebSocketManager.js";
export const Constants = {
GATEWAY: `wss://gateway.discord.gg/?v=${options.gateway_version}&encoding=json`
}
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`;