fix(server-sdk): opt undefined

This commit is contained in:
Neko Ayaka
2025-01-17 01:31:39 +08:00
parent 7b7fb2dd5c
commit 741e4b2afa
2 changed files with 4 additions and 4 deletions
+3 -3
View File
@@ -25,12 +25,12 @@ export class Client {
private authenticateAttempts = 0
constructor(options: ClientOptions) {
const opts = defu<Required<ClientOptions>, Required<Omit<ClientOptions, 'name' | 'token'>>[]>(
this.opts = defu<Required<ClientOptions>, Required<Omit<ClientOptions, 'name' | 'token'>>[]>(
options,
{ url: 'ws://localhost:6121/ws', possibleEvents: [] },
)
this.websocket = new WebSocket(opts.url)
this.websocket = new WebSocket(this.opts.url)
this.onEvent('module:authenticated', async (event) => {
const auth = event.data.authenticated
@@ -47,7 +47,7 @@ export class Client {
this.websocket.onmessage = this.handleMessage.bind(this)
this.websocket.onopen = () => {
if (opts.token) {
if (this.opts.token) {
this.tryAuthenticate()
}
else {
+1 -1
View File
@@ -14,7 +14,7 @@ async function main() {
// await WhisperLargeV3Pipeline.getInstance()
const client = new Client({ intents: [GatewayIntentBits.Guilds, GatewayIntentBits.GuildVoiceStates] })
const airiClient = new AiriClient({ name: 'discord-bot', possibleEvents: ['input:text', 'input:text:voice', 'input:voice'] })
const airiClient = new AiriClient({ name: 'discord-bot', possibleEvents: ['input:text', 'input:text:voice', 'input:voice'], token: 'abcd' })
const voiceManager = new VoiceManager(client, airiClient)
// When the client is ready, run this code (only once).