From: Fl_GUI Date: Sun, 7 Dec 2025 20:22:00 +0000 (+0100) Subject: add voice channel effect X-Git-Url: https://git.openfl.eu/?a=commitdiff_plain;h=refs%2Fheads%2Fjsmain;p=va4s.git add voice channel effect --- diff --git a/src/index.ts b/src/index.ts index fc98f36..b8d76cf 100644 --- a/src/index.ts +++ b/src/index.ts @@ -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) diff --git a/src/sammi.ts b/src/sammi.ts index ba50fc2..acb0bc6 100644 --- a/src/sammi.ts +++ b/src/sammi.ts @@ -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() +}