mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
remake yabai command to be more fun!
This commit is contained in:
@@ -1,5 +1,4 @@
|
|||||||
import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base";
|
import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base";
|
||||||
import { type HelixSendChatMessageParams } from "@twurple/api";
|
|
||||||
import { User } from "../user";
|
import { User } from "../user";
|
||||||
|
|
||||||
/** The Command class represents a command */
|
/** The Command class represents a command */
|
||||||
@@ -34,9 +33,16 @@ for (const file of files) {
|
|||||||
export default commands;
|
export default commands;
|
||||||
export { intents };
|
export { intents };
|
||||||
|
|
||||||
import { singleUserMode, chatterApi, chatterId, streamerId } from "..";
|
import { singleUserMode, chatterApi, chatterId, streamerId, streamerApi } from "..";
|
||||||
|
|
||||||
/** Helper function to send a message to the stream */
|
/** Helper function to send a message to the stream */
|
||||||
export const sendMessage = async (message: string, replyParentMessageId?: string) => {
|
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 }));
|
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 });
|
||||||
|
};
|
||||||
|
|||||||
@@ -1,16 +1,18 @@
|
|||||||
import { Command, sendMessage } from ".";
|
import { Command, doTimeout, sendMessage } from ".";
|
||||||
import { type HelixSendChatMessageParams } from "@twurple/api";
|
|
||||||
|
|
||||||
// Remake of the !yabai command in ttv/kiara_tv
|
// Remake of the !yabai command in ttv/kiara_tv
|
||||||
export default new Command('yabai',
|
export default new Command('yabai',
|
||||||
['yabai', 'goon'],
|
['yabai', 'goon'],
|
||||||
[],
|
['moderator:manage:banned_users'],
|
||||||
async msg => {
|
async msg => {
|
||||||
const rand = Math.floor(Math.random() * 100) + 1;
|
const rand = Math.floor(Math.random() * 100) + 1;
|
||||||
if (rand < 25) await sendMessage(`${rand}% yabai! chumpi4Bewwy`, msg.messageId);
|
if (rand < 25) sendMessage(`${rand}% yabai! GIGACHAD`, msg.messageId);
|
||||||
else if (rand < 50) await sendMessage(`${rand}% yabai chumpi4Hustle`, msg.messageId);
|
else if (rand < 50) sendMessage(`${rand}% yabai POGGERS`, msg.messageId);
|
||||||
else if (rand === 50) await sendMessage(`${rand}% yabai kiawaBlank`, msg.messageId);
|
else if (rand === 50) sendMessage(`${rand}% yabai ok`, msg.messageId);
|
||||||
else if (rand < 80) await sendMessage(`${rand}% yabai chumpi4Shock`, msg.messageId);
|
else if (rand < 90) sendMessage(`${rand}% yabai AINTNOWAY`, msg.messageId);
|
||||||
else await sendMessage(`${rand}% yabai chumpi4Jail`, msg.messageId);
|
else {
|
||||||
|
sendMessage(`${msg.chatterDisplayName} is ${rand}% yabai CAUGHT`);
|
||||||
|
doTimeout(msg.chatterId, 'TOO SUS');
|
||||||
|
};
|
||||||
}
|
}
|
||||||
);
|
);
|
||||||
|
|||||||
@@ -15,7 +15,8 @@ eventSub.onChannelChatMessage(streamerId, streamerId, async msg => {
|
|||||||
if (msg.messageText.startsWith(commandPrefix)) {
|
if (msg.messageText.startsWith(commandPrefix)) {
|
||||||
const commandSelection = msg.messageText.slice(commandPrefix.length).split(' ')[0]!;
|
const commandSelection = msg.messageText.slice(commandPrefix.length).split(' ')[0]!;
|
||||||
const selected = commands.get(commandSelection.toLowerCase());
|
const selected = commands.get(commandSelection.toLowerCase());
|
||||||
if (!selected) { await sendMessage(`${commandSelection} command does not exist`, { replyParentMessageId: msg.messageId }); return; };
|
if (!selected) { await sendMessage(`${commandSelection} command does not exist`, msg.messageId); return; };
|
||||||
await selected.execute(msg, user!);
|
try { await selected.execute(msg, user!); }
|
||||||
|
catch (err) { console.error(err); };
|
||||||
};
|
};
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user