1
0

♻️ Extract chatClient and actions into folders

This commit is contained in:
2021-12-26 01:16:23 +01:00
parent ca34a6a090
commit 93ef43ef12
10 changed files with 155 additions and 157 deletions

View File

@@ -0,0 +1,18 @@
import { chatClient } from "../..";
import { say } from "..";
// adds a user to vips
async function addVip(
channel: string,
username: string,
message?: string
): Promise<void> {
if (!message) {
message = `Otorgado VIP a @${username}.`;
}
await chatClient.addVip(channel, username);
say(channel, message);
}
export { addVip };

View File

@@ -0,0 +1,6 @@
import { addVip } from "./addVip";
import { removeVip } from "./removeVip";
import { say } from "./say";
import { timeout } from "./timeout";
export { say, timeout, addVip, removeVip };

View File

@@ -0,0 +1,18 @@
import { chatClient } from "../..";
import { say } from "..";
// removes a user from vips
async function removeVip(
channel: string,
username: string,
message?: string
): Promise<void> {
if (!message) {
message = `VIP de @${username} eliminado.`;
}
await chatClient.removeVip(channel, username);
say(channel, message);
}
export { removeVip };

View File

@@ -0,0 +1,8 @@
import { chatClient } from "../..";
// send a chat message
async function say(channel: string, message: string): Promise<void> {
await chatClient.say(channel, message);
}
export { say };

View File

@@ -0,0 +1,25 @@
import { chatClient } from "../..";
// timeouts a user in a channel
async function timeout(
channel: string,
username: string,
time?: number,
reason?: string
): Promise<void> {
if (!time) {
time = 60;
}
if (!reason) {
reason = "";
}
try {
await chatClient.timeout(channel, username, time, reason);
} catch (e) {
// user cannot be timed out
}
}
export { timeout };