created timeout function and minor changes

This commit is contained in:
2025-06-24 16:13:38 +02:00
parent 39448cbad4
commit 0437a6ba3c
6 changed files with 64 additions and 16 deletions

View File

@@ -33,16 +33,9 @@ for (const file of files) {
export default commands;
export { intents };
import { singleUserMode, chatterApi, chatterId, streamerId, streamerApi } from "..";
import { singleUserMode, chatterApi, chatterId, streamerId } from "..";
/** Helper function to send a message to the stream */
export const sendMessage = async (message: string, replyParentMessageId?: string) => {
singleUserMode ? await chatterApi.chat.sendChatMessage(streamerId, message, { replyParentMessageId }) : chatterApi.asUser(chatterId, async newapi => newapi.chat.sendChatMessage(streamerId, message, { replyParentMessageId }));
};
/** Helper function to timeout a specific user */
export const doTimeout = async (userid: string, reason: string, duration = 60) => {
// TODO: make sure mods lose their sword, THEN get timed out, and get the sword back after timeout expires (check v1 code for implementation)
if ([chatterId, streamerId].includes(userid)) return; // make sure unbannable users don't get banned
await streamerApi.moderation.banUser(streamerId, { user: userid, reason, duration });
};

View File

@@ -1,10 +1,11 @@
import { Command, doTimeout, sendMessage } from ".";
import { Command, sendMessage } from ".";
import { timeout } from "../lib/timeout";
// Remake of the !yabai command in ttv/kiara_tv
export default new Command('yabai',
['yabai', 'goon'],
['moderator:manage:banned_users'],
async msg => {
async (msg, user) => {
const rand = Math.floor(Math.random() * 100) + 1;
if (rand < 25) sendMessage(`${rand}% yabai! GIGACHAD`, msg.messageId);
else if (rand < 50) sendMessage(`${rand}% yabai POGGERS`, msg.messageId);
@@ -12,7 +13,7 @@ export default new Command('yabai',
else if (rand < 90) sendMessage(`${rand}% yabai AINTNOWAY`, msg.messageId);
else {
sendMessage(`${msg.chatterDisplayName} is ${rand}% yabai CAUGHT`);
doTimeout(msg.chatterId, 'TOO SUS');
timeout(user, "TOO YABAI!", 60);
};
}
);