rename bot directory to src, add chatwidget

This commit is contained in:
2025-07-09 16:50:16 +02:00
parent 8fd889856b
commit 3e025a586a
59 changed files with 417 additions and 1 deletions

14
src/commands/addadmin.ts Normal file
View File

@@ -0,0 +1,14 @@
import { Command, sendMessage } from ".";
import { addAdmin } from "../lib/admins";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('addadmin', ['addadmin'], 'streamer', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const data = await addAdmin(target.id);
if (data === 1) await sendMessage(`${target.displayName} is now an admin`, msg.messageId);
else await sendMessage(`${target.displayName} is already an admin`, msg.messageId);
}, false);

View File

@@ -0,0 +1,25 @@
import { Command, sendMessage } from ".";
import { getUserRecord } from "../db/dbUser";
import { changeBalance } from "../lib/changeBalance";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('admindonate', ['admindonate'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a user', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const userRecord = await getUserRecord(target);
if (!args[1]) { await sendMessage('Please specify the amount qweribucks you want to give', msg.messageId); return; };
const amount = Number(args[1]);
if (isNaN(amount)) { await sendMessage(`${args[1]} is not a valid amount`); return; };
if (await target.itemLock()) { await sendMessage('Cannot give qweribucks: item lock is set', msg.messageId); return; };
await target.setLock();
const data = await changeBalance(target, userRecord, amount);
if (!data) {
await sendMessage(`Failed to give ${target.displayName} ${amount} qweribuck${amount === 1 ? '' : 's'}`, msg.messageId);
} else {
await sendMessage(`${target.displayName} now has ${data.balance} qweribuck${data.balance === 1 ? '' : 's'}`, msg.messageId);
};
await target.clearLock();
});

29
src/commands/admingive.ts Normal file
View File

@@ -0,0 +1,29 @@
import { Command, sendMessage } from ".";
import { getUserRecord } from "../db/dbUser";
import items, { changeItemCount } from "../items";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('admingive', ['admingive'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a user', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const userRecord = await getUserRecord(target);
if (!args[1]) { await sendMessage('Please specify an item to give', msg.messageId); return; };
const item = items.get(args[1].toLowerCase());
if (!item) { await sendMessage(`Item ${args[1]} doesn't exist`, msg.messageId); return; };
if (!args[2]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; };
const amount = Number(args[2]);
if (isNaN(amount)) { await sendMessage(`${args[2]} is not a valid amount`); return; };
if (await target.itemLock()) { await sendMessage('Cannot give item: item lock is set', msg.messageId); return; };
await target.setLock();
const data = await changeItemCount(target, userRecord, item.name, amount);
if (data) {
const newamount = data.inventory[item.name]!;
await sendMessage(`${target.displayName} now has ${newamount} ${item.prettyName + (newamount === 1 ? '' : item.plural)}`, msg.messageId);
} else {
await sendMessage(`Failed to give ${target.displayName} ${amount} ${item.prettyName + (amount === 1 ? '' : item.plural)}`, msg.messageId);
};
await target.clearLock();
});

View File

@@ -0,0 +1,14 @@
import { redis } from "bun";
import { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
import { namedcheers } from "../cheers";
export default new Command('disablecheer', ['disablecheer'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a cheer to disable', msg.messageId); return; };
const selection = namedcheers.get(args[0].toLowerCase());
if (!selection) { await sendMessage(`There is no ${args[0]} cheer`, msg.messageId); return; };
const result = await redis.sadd('disabledcheers', selection.name);
if (result === 0) { await sendMessage(`The ${selection.name} cheer is already disabled`, msg.messageId); return; };
await sendMessage(`Successfully disabled the ${selection.name} cheer`, msg.messageId);
}, false);

View File

@@ -0,0 +1,14 @@
import { redis } from "bun";
import commands, { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
export default new Command('disablecommand', ['disablecommand'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a command to disable', msg.messageId); return; };
const selection = commands.get(args[0].toLowerCase());
if (!selection) { await sendMessage(`There is no ${args[0]} command`, msg.messageId); return; };
if (!selection.disableable) { await sendMessage(`Cannot disable ${selection.name} as the command is not disableable`, msg.messageId); return; };
const result = await redis.sadd('disabledcommands', selection.name);
if (result === 0) { await sendMessage(`The ${selection.name} command is already disabled`, msg.messageId); return; };
await sendMessage(`Successfully disabled the ${selection.name} command`, msg.messageId);
}, false);

View File

@@ -0,0 +1,48 @@
import { Command, sendMessage } from ".";
import type { userRecord } from "../db/connection";
import { getUserRecord } from "../db/dbUser";
import parseCommandArgs from "../lib/parseCommandArgs";
import { changeBalance } from "../lib/changeBalance";
import { User } from "../user";
import logger from "../lib/logger";
export default new Command('donate', ['donate'], 'chatter', async (msg, user) => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a user', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
if (target.username === user.username) { await sendMessage("You can't give yourself qweribucks", msg.messageId); return; };
const targetRecord = await getUserRecord(target);
if (!args[1]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; };
const amount = Number(args[1]);
if (isNaN(amount) || amount < 0) { await sendMessage(`${args[1]} is not a valid amount`); return; };
const userRecord = await getUserRecord(user);
if (userRecord.balance < amount) { await sendMessage(`You can't give qweribucks you don't have!`, msg.messageId); return; };
if (await user.itemLock() || await target.itemLock()) { await sendMessage('Cannot give qweribucks', msg.messageId); return; };
await Promise.all([
user.setLock(),
target.setLock()
]);
const data = await Promise.all([
await changeBalance(target, targetRecord, amount),
await changeBalance(user, userRecord, -amount)
]);
if (!data.includes(false)) {
const { balance: newamount } = data[0] as userRecord;
await sendMessage(`${user.displayName} gave ${amount} qweribuck${amount === 1 ? '' : 's'} to ${target.displayName}. They now have ${newamount} qweribuck${newamount === 1 ? '' : 's'}`, msg.messageId);
} else {
// TODO: Rewrite this section
await sendMessage(`Failed to give ${target.displayName} ${amount} qbuck${(amount === 1 ? '' : 's')}`, msg.messageId);
logger.err(`WARNING: Qweribucks donation failed: target success: ${data[0] !== false}, donator success: ${data[1] !== false}`);
};
await Promise.all([
user.clearLock(),
target.clearLock()
]);
});

View File

@@ -0,0 +1,14 @@
import { redis } from "bun";
import { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
import { namedcheers } from "../cheers";
export default new Command('enablecheer', ['enablecheer'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a cheer to enable', msg.messageId); return; };
const selection = namedcheers.get(args[0].toLowerCase());
if (!selection) { await sendMessage(`There is no ${args[0]} cheer`, msg.messageId); return; };
const result = await redis.srem('disabledcheers', selection.name);
if (result === 0) { await sendMessage(`The ${selection.name} cheer isn't disabled`, msg.messageId); return; };
await sendMessage(`Successfully enabled the ${selection.name} cheer`, msg.messageId);
}, false);

View File

@@ -0,0 +1,13 @@
import { redis } from "bun";
import commands, { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
export default new Command('enablecommand', ['enablecommand'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a command to enable', msg.messageId); return; };
const selection = commands.get(args[0].toLowerCase());
if (!selection) { await sendMessage(`There is no ${args[0]} command`, msg.messageId); return; };
const result = await redis.srem('disabledcommands', selection.name);
if (result === 0) { await sendMessage(`The ${selection.name} command isn't disabled`, msg.messageId); return; };
await sendMessage(`Successfully enabled the ${selection.name} command`, msg.messageId);
}, false);

13
src/commands/getadmins.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Command, sendMessage } from ".";
import { getAdmins } from "../lib/admins";
import { User } from "../user";
export default new Command('getadmins', ['getadmins'], 'chatter', async msg => {
const admins = await getAdmins()
const adminnames: string[] = [];
for (const id of admins) {
const admin = await User.initUserId(id);
adminnames.push(admin?.displayName!);
};
await sendMessage(`Current admins: ${adminnames.join(', ')}`, msg.messageId);
}, false);

View File

@@ -0,0 +1,12 @@
import { Command, sendMessage } from ".";
import { getUserRecord } from "../db/dbUser";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('getbalance', ['getbalance', 'balance', 'qbucks', 'qweribucks', 'wallet', 'getwallet'], 'chatter', async (msg, user) => {
const args = parseCommandArgs(msg.messageText);
const target = args[0] ? await User.initUsername(args[0].toLowerCase()) : user;
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist!`, msg.messageId); return; };
const data = await getUserRecord(target);
await sendMessage(`${target.displayName} has ${data.balance} qbuck${data.balance === 1 ? '' : 's'}`, msg.messageId);
});

33
src/commands/getcheers.ts Normal file
View File

@@ -0,0 +1,33 @@
import { redis } from "bun";
import { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
import { namedcheers } from "../cheers";
export default new Command('getcheers', ['getcheers', 'getcheer'], 'chatter', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage(`A full list of cheers can be found here: https://github.com/qwerinope/qweribot#cheers`, msg.messageId); return; };
const disabledcheers = await redis.smembers('disabledcheers');
const cheerstrings: string[] = [];
if (args[0].toLowerCase() === "enabled") {
for (const [name, cheer] of Array.from(namedcheers.entries())) {
if (disabledcheers.includes(name)) continue;
cheerstrings.push(`${cheer.amount}: ${name}`);
};
const last = cheerstrings.pop();
if (!last) { await sendMessage("No enabled cheers", msg.messageId); return; };
await sendMessage(cheerstrings.length === 0 ? last : cheerstrings.join(', ') + " and " + last, msg.messageId);
} else if (args[0].toLowerCase() === "disabled") {
for (const [name, cheer] of Array.from(namedcheers.entries())) {
if (!disabledcheers.includes(name)) continue;
cheerstrings.push(`${cheer.amount}: ${name}`);
};
const last = cheerstrings.pop();
if (!last) { await sendMessage("No disabled cheers", msg.messageId); return; };
await sendMessage(cheerstrings.length === 0 ? last : cheerstrings.join(', ') + " and " + last, msg.messageId);
} else await sendMessage('Please specify if you want the enabled or disabled cheers', msg.messageId);
}, false);

View File

@@ -0,0 +1,23 @@
import { redis } from "bun";
import { basecommands, Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
export default new Command('getcommands', ['getcommands', 'getc'], 'chatter', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage(`A full list of commands can be found here: https://github.com/qwerinope/qweribot#commands-1`, msg.messageId); return; };
const disabledcommands = await redis.smembers('disabledcommands');
if (args[0].toLowerCase() === 'enabled') {
const commandnames: string[] = [];
for (const [name, command] of Array.from(basecommands.entries())) {
if (command.usertype !== 'chatter') continue; // Admin only commands should be somewhat hidden
if (disabledcommands.includes(name)) continue;
commandnames.push(name);
};
if (commandnames.length === 0) await sendMessage('No commands besides non-disableable commands are enabled', msg.messageId);
else await sendMessage(`Currently enabled commands: ${commandnames.join(', ')}`, msg.messageId);
} else if (args[0].toLowerCase() === 'disabled') {
if (disabledcommands.length === 0) await sendMessage('No commands are disabled', msg.messageId);
else await sendMessage(`Currently disabled commands: ${disabledcommands.join(', ')}`);
}
else await sendMessage('Please specify if you want the enabled or disabled commands', msg.messageId);
}, false);

View File

@@ -0,0 +1,26 @@
import { Command, sendMessage } from ".";
import { getUserRecord } from "../db/dbUser";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
import items from "../items";
export default new Command('inventory', ['inv', 'inventory'], 'chatter', async (msg, user) => {
const args = parseCommandArgs(msg.messageText);
let target: User = user;
if (args[0]) {
const obj = await User.initUsername(args[0].toLowerCase());
if (!obj) { await sendMessage(`User ${args[0]} doesn't exist`, msg.messageId); return; };
target = obj;
};
const data = await getUserRecord(target);
const messagedata: string[] = [];
for (const [key, amount] of Object.entries(data.inventory)) {
if (amount === 0) continue;
const itemselection = items.get(key);
messagedata.push(`${itemselection?.prettyName}${amount === 1 ? '' : itemselection?.plural}: ${amount}`);
};
if (messagedata.length === 0) { await sendMessage(`${target.displayName} has no items`, msg.messageId); return; };
await sendMessage(`Inventory of ${target.displayName}: ${messagedata.join(', ')}`, msg.messageId);
});

View File

@@ -0,0 +1,16 @@
import { Command, sendMessage } from ".";
import { streamerApi, streamerId } from "..";
import { buildTimeString } from "../lib/dateManager";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('gettimeout', ['gett', 'gettimeout'], 'chatter', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
const data = await streamerApi.moderation.getBannedUsers(streamerId, { userId: target.id }).then(a => a.data);
if (!data[0]) { await sendMessage(`Chatter ${target.displayName} isn't timed out`, msg.messageId); return; };
if (data[0].expiryDate) { await sendMessage(`${target.displayName} is still timed out for ${buildTimeString(data[0].expiryDate.getTime(), Date.now())}`, msg.messageId); return; };
await sendMessage(`${target.displayName} is permanently banned`, msg.messageId);
});

49
src/commands/giveitem.ts Normal file
View File

@@ -0,0 +1,49 @@
import { Command, sendMessage } from ".";
import type { userRecord } from "../db/connection";
import { getUserRecord } from "../db/dbUser";
import items, { changeItemCount } from "../items";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
import logger from "../lib/logger";
export default new Command('give', ['give'], 'chatter', async (msg, user) => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a user', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
if (target.username === user.username) { await sendMessage("You can't give yourself items", msg.messageId); return; };
const targetRecord = await getUserRecord(target);
if (!args[1]) { await sendMessage('Please specify an item to give', msg.messageId); return; };
const item = items.get(args[1].toLowerCase());
if (!item) { await sendMessage(`Item ${args[1]} doesn't exist`, msg.messageId); return; };
if (!args[2]) { await sendMessage('Please specify the amount of the item you want to give', msg.messageId); return; };
const amount = Number(args[2]);
if (isNaN(amount) || amount < 0) { await sendMessage(`${args[2]} is not a valid amount`); return; };
const userRecord = await getUserRecord(user);
if (userRecord.inventory[item.name]! < amount) { await sendMessage(`You can't give items you don't have!`, msg.messageId); return; };
if (await user.itemLock() || await target.itemLock()) { await sendMessage('Cannot give item', msg.messageId); return; };
await Promise.all([
user.setLock(),
target.setLock()
]);
const data = await Promise.all([
await changeItemCount(target, targetRecord, item.name, amount),
await changeItemCount(user, userRecord, item.name, -amount)
]);
if (!data.includes(false)) {
const tempdata = data[0] as userRecord;
const newamount = tempdata.inventory[item.name]!;
await sendMessage(`${user.displayName} gave ${amount} ${item.prettyName + (amount === 1 ? '' : item.plural)} to ${target.displayName}. They now have ${newamount} ${item.prettyName + (newamount === 1 ? '' : item.plural)}`, msg.messageId);
} else {
// TODO: Rewrite this section
await sendMessage(`Failed to give ${target.displayName} ${amount} ${item.prettyName + (amount === 1 ? '' : item.plural)}`, msg.messageId);
logger.warn(`WARNING: Item donation failed: target success: ${data[0] !== false}, donator success: ${data[1] !== false}`);
};
await user.clearLock();
await target.clearLock();
});

50
src/commands/index.ts Normal file
View File

@@ -0,0 +1,50 @@
import { EventSubChannelChatMessageEvent } from "@twurple/eventsub-base";
import { User } from "../user";
export type userType = 'chatter' | 'admin' | 'streamer';
/** The Command class represents a command */
export class Command {
public readonly name: string;
public readonly aliases: string[];
public readonly usertype: userType;
public readonly disableable: boolean;
public readonly execute: (message: EventSubChannelChatMessageEvent, sender: User) => Promise<void>;
constructor(name: string, aliases: string[], usertype: userType, execution: (message: EventSubChannelChatMessageEvent, sender: User) => Promise<void>, disableable?: boolean) {
this.name = name.toLowerCase();
this.aliases = aliases;
this.usertype = usertype;
this.execute = execution;
this.disableable = disableable ?? true;
};
};
import { readdir } from 'node:fs/promises';
const commands = new Map<string, Command>; // This map has all command/item aliases mapped to commands/items (many-to-one)
const basecommands = new Map<string, Command>; // This map has all command names mapped to commands (one-to-one) (no items)
const files = await readdir(import.meta.dir);
for (const file of files) {
if (!file.endsWith('.ts')) continue;
if (file === import.meta.file) continue;
const command: Command = await import(import.meta.dir + '/' + file.slice(0, -3)).then(a => a.default);
basecommands.set(command.name, command);
for (const alias of command.aliases) {
commands.set(alias, command); // Since it's not a primitive type the map is filled with references to the command, not the actual object
};
};
import items from "../items";
for (const [name, item] of Array.from(items)) {
commands.set(name, item); // As Item is basically just Command but with more parameters, this should work fine
};
export default commands;
export { basecommands };
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 }));
};

11
src/commands/iteminfo.ts Normal file
View File

@@ -0,0 +1,11 @@
import { Command, sendMessage } from ".";
import items from "../items";
import parseCommandArgs from "../lib/parseCommandArgs";
export default new Command('iteminfo', ['iteminfo', 'itemhelp', 'info'], 'chatter', async msg => {
const messagequery = parseCommandArgs(msg.messageText).join(' ');
if (!messagequery) { await sendMessage('Please specify an item you would like to get info about', msg.messageId); return; };
const selection = items.get(messagequery.toLowerCase());
if (!selection) { await sendMessage(`'${messagequery}' is not an item`, msg.messageId); return; };
await sendMessage(`Name: ${selection.prettyName}, Description: ${selection.description}, Aliases: ${selection.aliases.join(', ')}`, msg.messageId);
});

13
src/commands/itemlock.ts Normal file
View File

@@ -0,0 +1,13 @@
import { Command, sendMessage } from ".";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('itemlock', ['itemlock'], 'admin', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a chatter to toggle the lock for', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage('Targeted user does not exist', msg.messageId); return; };
const status = await target.itemLock();
status ? await target.clearLock() : await target.setLock();
await sendMessage(`Successfully ${status ? 'cleared' : 'set'} the item lock on ${target.displayName}`, msg.messageId);
}, false);

6
src/commands/ping.ts Normal file
View File

@@ -0,0 +1,6 @@
import { Command, sendMessage } from ".";
// This command is purely for testing
export default new Command('ping', ['ping'], 'chatter', async msg => {
await sendMessage('pong!', msg.messageId);
});

View File

@@ -0,0 +1,16 @@
import { Command, sendMessage } from ".";
import { streamerUsers } from "..";
import { removeAdmin } from "../lib/admins";
import parseCommandArgs from "../lib/parseCommandArgs";
import { User } from "../user";
export default new Command('removeadmin', ['removeadmin'], 'streamer', async msg => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify a target', msg.messageId); return; };
const target = await User.initUsername(args[0].toLowerCase());
if (!target) { await sendMessage(`Chatter ${args[0]} doesn't exist`, msg.messageId); return; };
if (streamerUsers.includes(target.id)) { await sendMessage(`Can't remove admin ${target.displayName} as they are managed by the bot program`, msg.messageId); return; };
const data = await removeAdmin(target.id);
if (data === 1) await sendMessage(`${target.displayName} is no longer an admin`, msg.messageId);
else await sendMessage(`${target.displayName} isn't an admin`, msg.messageId);
}, false);

15
src/commands/seiso.ts Normal file
View File

@@ -0,0 +1,15 @@
import { Command, sendMessage } from ".";
import { timeout } from "../lib/timeout";
export default new Command('seiso', ['seiso'], 'chatter', async (msg, user) => {
const rand = Math.floor(Math.random() * 101);
if (rand > 75) await sendMessage(`${rand}% seiso YAAAA`, msg.messageId);
else if (rand > 51) await sendMessage(`${rand}% seiso POGGERS`, msg.messageId);
else if (rand === 50) await sendMessage(`${rand}% seiso ok`, msg.messageId);
else if (rand > 30) await sendMessage(`${rand}% seiso SWEAT`, msg.messageId);
else if (rand > 10) await sendMessage(`${rand}% seiso catErm`, msg.messageId);
else await Promise.all([
sendMessage(`${rand}% seiso RIPBOZO`),
timeout(user, 'TOO YABAI!', 60)
]);
});

11
src/commands/testcheer.ts Normal file
View File

@@ -0,0 +1,11 @@
import { Command, sendMessage } from ".";
import { handleCheer } from "../events/message";
import parseCommandArgs from "../lib/parseCommandArgs";
export default new Command('testcheer', ['testcheer'], 'streamer', async (msg, user) => {
const args = parseCommandArgs(msg.messageText);
if (!args[0]) { await sendMessage('Please specify the amount of fake bits you want to send', msg.messageId); return; };
if (isNaN(Number(args[0]))) { await sendMessage(`${args[0]} is not a valid amout of bits`); return; };
const bits = Number(args.shift()); // we shift it so the amount of bits isn't part of the handleCheer message, we already know that args[0] can be parsed as a number so this is fine.
await handleCheer(msg, bits, user);
}, false);

12
src/commands/useitem.ts Normal file
View File

@@ -0,0 +1,12 @@
import { redis } from "bun";
import { Command, sendMessage } from ".";
import items from "../items";
export default new Command('use', ['use'], 'chatter', async (msg, user) => {
const messagequery = msg.messageText.trim().split(' ').slice(1);
if (!messagequery[0]) { await sendMessage('Please specify an item you would like to use', msg.messageId); return; };
const selection = items.get(messagequery[0].toLowerCase());
if (!selection) { await sendMessage(`'${messagequery[0]}' is not an item`, msg.messageId); return; };
if (await redis.sismember('disabledcommands', selection.name)) { await sendMessage(`The ${selection.prettyName} item is disabled`, msg.messageId); return; };
await selection.execute(msg, user);
}, false);

View File

@@ -0,0 +1,8 @@
import { redis } from "bun";
import { Command, sendMessage } from ".";
export default new Command('vulnchatters', ['vulnchatters', 'vulnc'], 'chatter', async msg => {
const data = await redis.keys('vulnchatters:*');
const one = data.length === 1;
await sendMessage(`There ${one ? 'is' : 'are'} ${data.length} vulnerable chatter${one ? '' : 's'}`, msg.messageId);
});

15
src/commands/yabai.ts Normal file
View File

@@ -0,0 +1,15 @@
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'], 'chatter', async (msg, user) => {
const rand = Math.floor(Math.random() * 101);
if (rand < 25) sendMessage(`${rand}% yabai! GIGACHAD`, msg.messageId);
else if (rand < 50) sendMessage(`${rand}% yabai POGGERS`, msg.messageId);
else if (rand === 50) sendMessage(`${rand}% yabai ok`, msg.messageId);
else if (rand < 90) sendMessage(`${rand}% yabai AINTNOWAY`, msg.messageId);
else await Promise.all([
sendMessage(`${msg.chatterDisplayName} is ${rand}% yabai CAUGHT`),
timeout(user, "TOO YABAI!", 60)
]);
});