import type { UserIdResolvable } from "@twurple/api"; import { Config } from "../config/config"; import { apiClient } from "../core/api-client"; import { getUserId } from "./general"; import { logError } from "./logger"; export async function timeoutByIds( channelId: UserIdResolvable, userId: UserIdResolvable, duration: number, reason: string, ): Promise { if (!channelId || !userId || !duration) { logError(`timout id command missing a required parameter`); } await apiClient.asUser(Config.bot_user_id, async (apiClient) => apiClient.moderation.banUser(channelId, { user: userId, duration, reason }), ); } export async function timeout( channelName: string, userName: string, duration: number, reason: string, ): Promise { if (!channelName || !userName || !duration) { logError(`timout name command missing a required parameter`); } const channelId = await getUserId(channelName); const userId = await getUserId(userName); await timeoutByIds(channelId, userId, duration, reason); } export async function purgeByIds( channelId: UserIdResolvable, userId: UserIdResolvable, ): Promise { if (!channelId || !userId) { logError(`purge id command missing a required parameter`); } await timeoutByIds(channelId, userId, 1, "purged"); } export async function purge( channelName: string, userName: string, ): Promise { if (!channelName || !userName) { logError(`purge name command missing a required parameter`); } const channelId = await getUserId(channelName); const userId = await getUserId(userName); await purgeByIds(channelId, userId); }