♻️ Extract chatClient and actions into folders
This commit is contained in:
18
src/backend/chatClient/clientActions/addVip/index.ts
Normal file
18
src/backend/chatClient/clientActions/addVip/index.ts
Normal 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 };
|
6
src/backend/chatClient/clientActions/index.ts
Normal file
6
src/backend/chatClient/clientActions/index.ts
Normal 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 };
|
18
src/backend/chatClient/clientActions/removeVip/index.ts
Normal file
18
src/backend/chatClient/clientActions/removeVip/index.ts
Normal 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 };
|
8
src/backend/chatClient/clientActions/say/index.ts
Normal file
8
src/backend/chatClient/clientActions/say/index.ts
Normal 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 };
|
25
src/backend/chatClient/clientActions/timeout/index.ts
Normal file
25
src/backend/chatClient/clientActions/timeout/index.ts
Normal 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 };
|
Reference in New Issue
Block a user