【问题标题】:ReferenceError: Cannot access 'options' before initialization but 'options' is initalized before useReferenceError:在初始化之前无法访问“选项”,但“选项”在使用前已初始化
【发布时间】:2023-03-02 22:15:01
【问题描述】:

此时我真的一无所知,并尝试查找我能想到的所有内容,但我的代码出现此错误:

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`
}

WebSocketManager.js(只显示一个 sn-p)

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'
}

【问题讨论】:

    标签: api discord options referenceerror


    【解决方案1】:

    我已经修复了它,虽然使用了一种不同的方法。

    对于那些可能需要它的人,

    export const Gateway = {
        URL: undefined,
        VERSION: 9
    }
    
    Gateway.URL = `wss://gateway.discord.gg/?v=${Gateway.VERSION}&encoding=json`;
    

    【讨论】:

      猜你喜欢
      • 2020-12-29
      • 2021-09-10
      • 2020-10-23
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-03-16
      相关资源
      最近更新 更多