Send status messages to correct channel

This commit is contained in:
Leppunen 2021-09-07 00:11:35 +03:00
parent 6a16a7e07f
commit 4c55097019

View file

@ -59,7 +59,7 @@ const fetchUrlList = async (list) => {
return listMetaBody; return listMetaBody;
}; };
const runList = async (listData, listID, channel) => { const runList = async (listData, listID, channel, sourceChannel) => {
const banArr = listData.split('\n'); const banArr = listData.split('\n');
const targetChannel = Config.UseParallelUniverse === true ? channel : `#${channel}`; const targetChannel = Config.UseParallelUniverse === true ? channel : `#${channel}`;
@ -88,7 +88,7 @@ const runList = async (listData, listID, channel) => {
await Promise.allSettled(promises); await Promise.allSettled(promises);
say(Config.Username, `${Config.UseParallelUniverse === true ? '[PU]' : ''} Chunk ${currentChunk}/${chunkCount} of ${listID} executed successfully on channel ${targetChannel}`); say(sourceChannel, `${Config.UseParallelUniverse === true ? '[PU]' : ''} Chunk ${currentChunk}/${chunkCount} of ${listID} executed successfully on channel ${targetChannel}`);
if (currentChunk === chunkCount) { if (currentChunk === chunkCount) {
break; break;
@ -231,27 +231,27 @@ if (!Config.IgnorePNSL) {
const channel = args[1]; const channel = args[1];
if (!listID) { if (!listID) {
return say(Config.Username, 'No list ID provided!'); return say(channelName, 'No list ID provided!');
} }
try { try {
if (channel) { if (channel) {
const mods = await listenClient.getMods(`#${channel}`); const mods = await listenClient.getMods(`#${channel}`);
if (!mods.includes(Config.Username)) { if (!mods.includes(Config.Username)) {
return say(Config.Username, `I am not a moderator in channel ${channel}!`); return say(channelName, `I am not a moderator in channel ${channel}!`);
} }
} }
if (!Config.IgnorePNSL) { if (!Config.IgnorePNSL) {
const data = await fetchList(listID); const data = await fetchList(listID);
await runList(data.listData, listID, channel || channelName); await runList(data.listData, listID, channel || channelName, channelName);
} else { } else {
const data = await fetchUrlList(listID); const data = await fetchUrlList(listID);
await runList(data, listID, channel || channelName); await runList(data, listID, channel || channelName, channelName);
} }
say(Config.Username, `${Config.UseParallelUniverse === true ? '[PU]' : ''} List ${listID} executed successfully on channel ${channel || channelName}`); say(channelName, `${Config.UseParallelUniverse === true ? '[PU]' : ''} List ${listID} executed successfully on channel ${channel || channelName}`);
} catch (e) { } catch (e) {
console.error(e); console.error(e);
return say(Config.Username, `Error Occurred! ${e.message}`); return say(channelName, `Error Occurred! ${e.message}`);
} }
} }
}); });