]> git.openfl.eu Git - va4s.git/commitdiff
add voice channel effect jsmain
authorFl_GUI <flor.guilini@hotmail.com>
Sun, 7 Dec 2025 20:22:00 +0000 (21:22 +0100)
committerFl_GUI <flor.guilini@hotmail.com>
Sun, 7 Dec 2025 20:22:00 +0000 (21:22 +0100)
src/index.ts
src/sammi.ts

index fc98f367ecbf535041613b18c2490aea83e0d89a..b8d76cf4e72e03d981cf631205585807b1b0f633 100644 (file)
@@ -2,7 +2,7 @@ import process from 'node:process'
 import 'dotenv/config';
 import { Client, GatewayIntentBits, VoiceChannel } from 'discord.js';
 import { connectToChannel } from './util/helpers.js';
-import {startSpeaking, stopSpeaking} from './sammi.js';
+import {startSpeaking, stopSpeaking, sendEffect } from './sammi.js';
 
 const token = process.env.TOKEN
 const channelId = process.env.CHANNEL!
@@ -35,6 +35,8 @@ function cleanup() {
   client.destroy()
 }
 
+client.on('voiceChannelEffectSend', sendEffect)
+
 process.on('exit', cleanup)
 process.on('SIGTERM', cleanup)
 process.on('SIGINT', cleanup)
index ba50fc2faded60dfbc59ec0445c63d48e3f74778..acb0bc61a2b0f5f23a0f3f6b96a64f60e353428d 100644 (file)
@@ -1,4 +1,5 @@
 import http from 'http'
+import { VoiceChannelEffect } from 'discord.js'
 
 const sammiEndpoint = `http://localhost:${process.env.SAMMIPORT!}/webhook`
   const passwrd = process.env.PASS || ""
@@ -30,3 +31,16 @@ export function stopSpeaking(userId : String) {
   req.on('error', console.error)
   req.end()
 }
+
+export function sendEffect(effect : VoiceChannelEffect) {
+  const mutData : any = effect
+  delete mutData.guild
+  mutData.trigger = "va4s:effect"
+  const data = JSON.stringify(mutData)
+
+  const req = http.request(sammiEndpoint, {method: 'POST', headers: headers(data)})
+  console.log(`User ${effect.userId} send effect ${effect.soundId}`)
+  req.write(data)
+  req.on('error', console.error)
+  req.end()
+}