add stats command to readme, implement optional stacking timeouts, fully rework timeout management

This commit is contained in:
2025-07-29 01:36:28 +02:00
parent f9615b77e6
commit cde679e583
7 changed files with 69 additions and 11 deletions

View File

@@ -1,16 +1,16 @@
import { Command, sendMessage } from "commands";
import { streamerApi, streamerId } from "main";
import { buildTimeString } from "lib/dateManager";
import parseCommandArgs from "lib/parseCommandArgs";
import User from "user";
import { timeoutDuration } from "lib/timeout";
export default new Command('gettimeout', ['gett', 'gettimeout'], 'chatter', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const data = await streamerApi.moderation.getBannedUsers(streamerId, { userId: target.id }).then(a => a.data);
if (!data[0]) { await sendMessage(`Chatter ${target.displayName} isn't timed out`, msg.messageId); return; };
if (data[0].expiryDate) { await sendMessage(`${target.displayName} is still timed out for ${buildTimeString(data[0].expiryDate.getTime(), Date.now())}`, msg.messageId); return; };
const data = await timeoutDuration(target);
if (data === false) { await sendMessage(`Chatter ${target.displayName} isn't timed out`, msg.messageId); return; };
if (data) { await sendMessage(`${target.displayName} is still timed out for ${buildTimeString(data * 1000, Date.now())}`, msg.messageId); return; };
await sendMessage(`${target.displayName} is permanently banned`, msg.messageId);
});

22
src/commands/stacking.ts Normal file
View File

@@ -0,0 +1,22 @@
import { redis } from "bun";
import { Command, sendMessage } from "commands";
import { isAdmin } from "lib/admins";
import parseCommandArgs from "lib/parseCommandArgs";
export default new Command('stacking', ['stacking'], 'chatter', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0] || !await isAdmin(msg.chatterId)) { await sendMessage(`Timeout stacking is currently ${await redis.exists('timeoutStacking') ? "on" : "off"}`, msg.messageId); return; };
// Only admins can reach this part of code
switch (args[0]) {
case 'enable':
case 'on':
await redis.set('timeoutStacking', '1');
await sendMessage('Timeout stacking is now on')
break;
case 'disable':
case 'off':
await redis.del('timeoutStacking');
await sendMessage('Timeout stacking is now off')
break;
};
}, false);