From 314eb05c82bee0756d6ab236903d2d1dd2d33b23 Mon Sep 17 00:00:00 2001 From: biglyderv Date: Fri, 28 Mar 2025 19:24:04 -0400 Subject: [PATCH] go to the right channel --- index.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/index.js b/index.js index 1321de4..8985373 100644 --- a/index.js +++ b/index.js @@ -3,6 +3,7 @@ import { spawn } from "node:child_process"; import { mkdir, cp } from 'node:fs/promises'; let sessions = {}; +let channels = {}; const { TOKEN, ID } = process.env; //const commands = []; @@ -29,11 +30,11 @@ client.on(Events.MessageCreate, async interaction => { let msg = interaction.content; let channel = interaction.channel.name; - if (channel.indexOf('play') == -1 && channel.indexOf('bot') == -1 && channel.indexOf('spam') == -1) return; + if (channel.indexOf('play') == -1 && channel.indexOf('bot') == -1 && channel.indexOf('spam') == -1) return; if (msg.startsWith('!')) { msg = `/${msg.slice(1)}`; - } + } let id = interaction.author.id; @@ -50,8 +51,8 @@ client.on(Events.MessageCreate, async interaction => { sessions[id].stdout.on('data', (chunk) => { if (chunk.toString().length > 1) { let str = chunk.toString(); - str = str.replaceAll(id,`<@${id}>`); - interaction.channel.send(str); + str = str.replaceAll(id, `<@${id}>`); + (channels[id] || interaction.channel).send(str); } }); sessions[id].on('close', () => { @@ -59,6 +60,8 @@ client.on(Events.MessageCreate, async interaction => { }) } + channels[id] = interaction.channel; + let msgs = msg.split('\n'); setTimeout(async function () {