mirror of
https://github.com/qwerinope/qweribot.git
synced 2025-12-19 08:41:39 +01:00
proper formatting and linting YAY, change cheer constructor to take object
This commit is contained in:
@@ -1,20 +1,31 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { addAdmin } from "lib/admins";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'addadmin',
|
||||
aliases: ['addadmin'],
|
||||
usertype: 'streamer',
|
||||
disableable: false,
|
||||
execution: 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 === "OK") await sendMessage(`${target.displayName} is now an admin`, msg.messageId);
|
||||
else await sendMessage(`${target.displayName} is already an admin`, msg.messageId);
|
||||
}
|
||||
name: "addadmin",
|
||||
aliases: ["addadmin"],
|
||||
usertype: "streamer",
|
||||
disableable: false,
|
||||
execution: 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 === "OK")
|
||||
await sendMessage(`${target.displayName} is now an admin`, msg.messageId);
|
||||
else
|
||||
await sendMessage(
|
||||
`${target.displayName} is already an admin`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,23 +1,40 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { redis } from "lib/redis";
|
||||
import { streamerUsers } from "main";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'addbot',
|
||||
aliases: ['addbot'],
|
||||
usertype: 'streamer',
|
||||
disableable: false,
|
||||
execution: 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(`Cannot change bot status of qweribot managed user`, msg.messageId); return; };
|
||||
const data = await redis.set(`user:${target.id}:bot`, '1');
|
||||
await target.clearVulnerable();
|
||||
if (data === "OK") await sendMessage(`${target.displayName} is now a bot`, msg.messageId);
|
||||
else await sendMessage(`${target.displayName} is already a bot`, msg.messageId);
|
||||
}
|
||||
name: "addbot",
|
||||
aliases: ["addbot"],
|
||||
usertype: "streamer",
|
||||
disableable: false,
|
||||
execution: 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(
|
||||
`Cannot change bot status of qweribot managed user`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const data = await redis.set(`user:${target.id}:bot`, "1");
|
||||
await target.clearVulnerable();
|
||||
if (data === "OK")
|
||||
await sendMessage(`${target.displayName} is now a bot`, msg.messageId);
|
||||
else
|
||||
await sendMessage(
|
||||
`${target.displayName} is already a bot`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,20 +1,34 @@
|
||||
import { addInvuln } from "lib/invuln";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { addInvuln } from "lib/invuln";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'addinvuln',
|
||||
aliases: ['addinvuln'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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 addInvuln(target.id);
|
||||
if (data === "OK") await sendMessage(`${target.displayName} is now an invuln`, msg.messageId);
|
||||
else await sendMessage(`${target.displayName} is already an invuln`, msg.messageId);
|
||||
}
|
||||
name: "addinvuln",
|
||||
aliases: ["addinvuln"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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 addInvuln(target.id);
|
||||
if (data === "OK")
|
||||
await sendMessage(
|
||||
`${target.displayName} is now an invuln`,
|
||||
msg.messageId,
|
||||
);
|
||||
else
|
||||
await sendMessage(
|
||||
`${target.displayName} is already an invuln`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,30 +1,54 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import { changeBalance } from "lib/changeBalance";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'admindonate',
|
||||
aliases: ['admindonate'],
|
||||
usertype: 'admin',
|
||||
execution: 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 = parseInt(args[1]);
|
||||
if (isNaN(amount)) { await sendMessage(`'${args[1]}' is not a valid amount`); return; };
|
||||
if (await target.itemLock()) { await sendMessage('Cannot give qweribucks (itemlock)', 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();
|
||||
}
|
||||
name: "admindonate",
|
||||
aliases: ["admindonate"],
|
||||
usertype: "admin",
|
||||
execution: 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 = parseInt(args[1], 10);
|
||||
if (Number.isNaN(amount)) {
|
||||
await sendMessage(`'${args[1]}' is not a valid amount`);
|
||||
return;
|
||||
}
|
||||
if (await target.itemLock()) {
|
||||
await sendMessage("Cannot give qweribucks (itemlock)", 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();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,34 +1,64 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import items, { changeItemCount } from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'admingive',
|
||||
aliases: ['admingive'],
|
||||
usertype: 'admin',
|
||||
execution: 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 = parseInt(args[2]);
|
||||
if (isNaN(amount)) { await sendMessage(`'${args[2]}' is not a valid amount`); return; };
|
||||
if (await target.itemLock()) { await sendMessage('Cannot give item (itemlock)', 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();
|
||||
}
|
||||
name: "admingive",
|
||||
aliases: ["admingive"],
|
||||
usertype: "admin",
|
||||
execution: 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 = parseInt(args[2], 10);
|
||||
if (Number.isNaN(amount)) {
|
||||
await sendMessage(`'${args[2]}' is not a valid amount`);
|
||||
return;
|
||||
}
|
||||
if (await target.itemLock()) {
|
||||
await sendMessage("Cannot give item (itemlock)", 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();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,34 +1,38 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getKDLeaderboard } from "db/dbUser";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import User from "user";
|
||||
|
||||
type KD = { user: User; kd: number; };
|
||||
type KD = { user: User; kd: number };
|
||||
|
||||
export default new Command({
|
||||
name: 'alltimekdleaderboard',
|
||||
aliases: ['alltimeleaderboard', 'alltimekdleaderboard'],
|
||||
usertype: 'chatter',
|
||||
execution: async msg => {
|
||||
const rawKD = await getKDLeaderboard();
|
||||
if (rawKD.length === 0) {
|
||||
await sendMessage(`No users on leaderboard yet!`, msg.messageId);
|
||||
return;
|
||||
};
|
||||
name: "alltimekdleaderboard",
|
||||
aliases: ["alltimeleaderboard", "alltimekdleaderboard"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg) => {
|
||||
const rawKD = await getKDLeaderboard();
|
||||
if (rawKD.length === 0) {
|
||||
await sendMessage(`No users on leaderboard yet!`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
const userKDs: KD[] = [];
|
||||
await Promise.all(rawKD.map(async userRecord => {
|
||||
const user = await User.initUserId(userRecord.userId.toString());
|
||||
if (!user) return;
|
||||
userKDs.push({ user, kd: userRecord.KD })
|
||||
}));
|
||||
const userKDs: KD[] = [];
|
||||
await Promise.all(
|
||||
rawKD.map(async (userRecord) => {
|
||||
const user = await User.initUserId(userRecord.userId.toString());
|
||||
if (!user) return;
|
||||
userKDs.push({ user, kd: userRecord.KD });
|
||||
}),
|
||||
);
|
||||
|
||||
userKDs.sort((a, b) => b.kd - a.kd);
|
||||
userKDs.sort((a, b) => b.kd - a.kd);
|
||||
|
||||
const txt: string[] = [];
|
||||
for (let i = 0; i < (userKDs.length < 10 ? userKDs.length : 10); i++) {
|
||||
txt.push(`${i + 1}. ${userKDs[i]?.user.displayName}: ${userKDs[i]?.kd.toFixed(2)}`);
|
||||
};
|
||||
const txt: string[] = [];
|
||||
for (let i = 0; i < (userKDs.length < 10 ? userKDs.length : 10); i++) {
|
||||
txt.push(
|
||||
`${i + 1}. ${userKDs[i]?.user.displayName}: ${userKDs[i]?.kd.toFixed(2)}`,
|
||||
);
|
||||
}
|
||||
|
||||
await sendMessage(`Alltime leaderboard: ${txt.join(' | ')}`, msg.messageId);
|
||||
}
|
||||
await sendMessage(`Alltime leaderboard: ${txt.join(" | ")}`, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,33 +1,45 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getTimeoutStats, getItemStats } from "lib/getStats";
|
||||
import { getItemStats, getTimeoutStats } from "lib/getStats";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'alltimestats',
|
||||
aliases: ['alltime', 'alltimestats'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
let target: User | null = user;
|
||||
if (args[0]) {
|
||||
target = await User.initUsername(args[0]);
|
||||
if (!target) { await sendMessage(`User ${args[0]} doesn't exist!`, msg.messageId); return; };
|
||||
};
|
||||
name: "alltimestats",
|
||||
aliases: ["alltime", "alltimestats"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
let target: User | null = user;
|
||||
if (args[0]) {
|
||||
target = await User.initUsername(args[0]);
|
||||
if (!target) {
|
||||
await sendMessage(`User ${args[0]} doesn't exist!`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const [timeout, item] = await Promise.all([getTimeoutStats(target, false), getItemStats(target, false)]);
|
||||
if (!timeout || !item) { await sendMessage(`ERROR: Something went wrong!`, msg.messageId); return; };
|
||||
const [timeout, item] = await Promise.all([
|
||||
getTimeoutStats(target, false),
|
||||
getItemStats(target, false),
|
||||
]);
|
||||
if (!timeout || !item) {
|
||||
await sendMessage(`ERROR: Something went wrong!`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
const KD = timeout.shot.blaster / timeout.hit.blaster;
|
||||
const KD = timeout.shot.blaster / timeout.hit.blaster;
|
||||
|
||||
await sendMessage(`
|
||||
await sendMessage(
|
||||
`
|
||||
Alltime: stats of ${target.displayName}:
|
||||
Users blasted: ${timeout.shot.blaster},
|
||||
Blasted by others: ${timeout.hit.blaster} (${isNaN(KD) ? 0 : KD.toFixed(2)} K/D).
|
||||
Blasted by others: ${timeout.hit.blaster} (${Number.isNaN(KD) ? 0 : KD.toFixed(2)} K/D).
|
||||
Grenades lobbed: ${item.grenade},
|
||||
TNT exploded: ${item.tnt}.
|
||||
Silver bullets fired: ${timeout.shot.silverbullet},
|
||||
Silver bullets taken: ${timeout.hit.silverbullet}.
|
||||
`, msg.messageId);
|
||||
}
|
||||
`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,19 +1,24 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getAnivTimeouts } from "db/dbAnivTimeouts";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'anivtimeouts',
|
||||
aliases: ['anivtimeouts', 'anivtimeout'],
|
||||
usertype: 'chatter',
|
||||
execution: 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 { dodge, dead } = await getAnivTimeouts(target);
|
||||
const percentage = ((dodge / (dead + dodge)) * 100);
|
||||
const message = `Aniv timeouts of ${target.displayName}: Dodge: ${dodge}, Timeout: ${dead}. Dodge percentage: ${isNaN(percentage) ? "0" : percentage.toFixed(1)}%`;
|
||||
await sendMessage(message, msg.messageId);
|
||||
}
|
||||
name: "anivtimeouts",
|
||||
aliases: ["anivtimeouts", "anivtimeout"],
|
||||
usertype: "chatter",
|
||||
execution: 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 { dodge, dead } = await getAnivTimeouts(target);
|
||||
const percentage = (dodge / (dead + dodge)) * 100;
|
||||
const message = `Aniv timeouts of ${target.displayName}: Dodge: ${dodge}, Timeout: ${dead}. Dodge percentage: ${Number.isNaN(percentage) ? "0" : percentage.toFixed(1)}%`;
|
||||
await sendMessage(message, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,15 +1,18 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import User from "user";
|
||||
import { redis } from "lib/redis";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'backshot',
|
||||
aliases: ['backshot'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
const targets = await redis.keys(`user:*:haschatted`);
|
||||
const selection = targets[Math.floor(Math.random() * targets.length)]!;
|
||||
const target = await User.initUserId(selection.slice(5, -11));
|
||||
await sendMessage(`${user.displayName} backshotted ${target?.displayName}`, msg.messageId);
|
||||
}
|
||||
name: "backshot",
|
||||
aliases: ["backshot"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
const targets = await redis.keys(`user:*:haschatted`);
|
||||
const selection = targets[Math.floor(Math.random() * targets.length)]!;
|
||||
const target = await User.initUserId(selection.slice(5, -11));
|
||||
await sendMessage(
|
||||
`${user.displayName} backshotted ${target?.displayName}`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,37 +1,62 @@
|
||||
import { getUserRecord, updateUserRecord } from "db/dbUser";
|
||||
import items from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import items from "items";
|
||||
import { getUserRecord, updateUserRecord } from "db/dbUser";
|
||||
|
||||
export default new Command({
|
||||
name: 'buyitem',
|
||||
aliases: ['buyitem', 'buy', 'purchase'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) { await sendMessage(`Specify the item you'd like to buy`, msg.messageId); return; };
|
||||
const selecteditem = items.get(args[0].toLowerCase());
|
||||
if (!selecteditem) { await sendMessage(`'${args[0]}' is not a valid item`, msg.messageId); return; };
|
||||
const amount = args[1] ? parseInt(args[1]) : 1;
|
||||
if (isNaN(amount) || amount < 1) { await sendMessage(`'${args[1]}' is not a valid amount to buy`, msg.messageId); return; };
|
||||
const totalcost = amount * selecteditem.price;
|
||||
name: "buyitem",
|
||||
aliases: ["buyitem", "buy", "purchase"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) {
|
||||
await sendMessage(`Specify the item you'd like to buy`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
const selecteditem = items.get(args[0].toLowerCase());
|
||||
if (!selecteditem) {
|
||||
await sendMessage(`'${args[0]}' is not a valid item`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
const amount = args[1] ? parseInt(args[1], 10) : 1;
|
||||
if (Number.isNaN(amount) || amount < 1) {
|
||||
await sendMessage(
|
||||
`'${args[1]}' is not a valid amount to buy`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const totalcost = amount * selecteditem.price;
|
||||
|
||||
if (await user.itemLock()) { await sendMessage('Cannot buy item (itemlock)', msg.messageId); return; };
|
||||
await user.setLock();
|
||||
if (await user.itemLock()) {
|
||||
await sendMessage("Cannot buy item (itemlock)", msg.messageId);
|
||||
return;
|
||||
}
|
||||
await user.setLock();
|
||||
|
||||
const userRecord = await getUserRecord(user);
|
||||
if (userRecord.balance < totalcost) { await sendMessage(`You don't have enough qbucks to buy ${amount} ${selecteditem.prettyName}${amount === 1 ? '' : selecteditem.plural}! You have ${userRecord.balance}, need ${totalcost}`); await user.clearLock(); return; };
|
||||
const userRecord = await getUserRecord(user);
|
||||
if (userRecord.balance < totalcost) {
|
||||
await sendMessage(
|
||||
`You don't have enough qbucks to buy ${amount} ${selecteditem.prettyName}${amount === 1 ? "" : selecteditem.plural}! You have ${userRecord.balance}, need ${totalcost}`,
|
||||
);
|
||||
await user.clearLock();
|
||||
return;
|
||||
}
|
||||
|
||||
if (userRecord.inventory[selecteditem.name]) userRecord.inventory[selecteditem.name]! += amount
|
||||
else userRecord.inventory[selecteditem.name] = amount;
|
||||
if (userRecord.inventory[selecteditem.name])
|
||||
userRecord.inventory[selecteditem.name]! += amount;
|
||||
else userRecord.inventory[selecteditem.name] = amount;
|
||||
|
||||
userRecord.balance -= totalcost;
|
||||
userRecord.balance -= totalcost;
|
||||
|
||||
await Promise.all([
|
||||
updateUserRecord(user, userRecord),
|
||||
sendMessage(`${user.displayName} bought ${amount} ${selecteditem.prettyName}${amount === 1 ? '' : selecteditem.plural} for ${totalcost} qbucks. They now have ${userRecord.inventory[selecteditem.name]} ${selecteditem.prettyName}${userRecord.inventory[selecteditem.name] === 1 ? '' : selecteditem.plural} and ${userRecord.balance} qbucks`, msg.messageId)
|
||||
]);
|
||||
await Promise.all([
|
||||
updateUserRecord(user, userRecord),
|
||||
sendMessage(
|
||||
`${user.displayName} bought ${amount} ${selecteditem.prettyName}${amount === 1 ? "" : selecteditem.plural} for ${totalcost} qbucks. They now have ${userRecord.inventory[selecteditem.name]} ${selecteditem.prettyName}${userRecord.inventory[selecteditem.name] === 1 ? "" : selecteditem.plural} and ${userRecord.balance} qbucks`,
|
||||
msg.messageId,
|
||||
),
|
||||
]);
|
||||
|
||||
await user.clearLock();
|
||||
}
|
||||
await user.clearLock();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { namedcheers } from "cheers";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { namedcheers } from "cheers";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'disablecheer',
|
||||
aliases: ['disablecheer'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "disablecheer",
|
||||
aliases: ["disablecheer"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,21 +1,42 @@
|
||||
import { redis } from "lib/redis";
|
||||
import commands from "commands";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'disablecommand',
|
||||
aliases: ['disablecommand'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "disablecommand",
|
||||
aliases: ["disablecommand"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,30 +1,55 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { disableRedeem, idMap, namedRedeems, sfxRedeems } from "pointRedeems";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import logger from "lib/logger";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
|
||||
export default new Command({
|
||||
name: 'disableRedeem',
|
||||
aliases: ['disableredeem'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: async msg => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) { await sendMessage("Please specify a point redemption to disable", msg.messageId); return; };
|
||||
if (args[0] === 'sfx' || args[0] === 'sound') {
|
||||
sfxRedeems.forEach(async redeem => {
|
||||
const id = idMap.get(redeem.name);
|
||||
if (!id) { await sendMessage(`Failed to find the ID for redeem ${redeem.name}`, msg.messageId); logger.err(`Failed to find the ID for ${redeem.name} while enabling`); return; };
|
||||
await disableRedeem(redeem, id);
|
||||
});
|
||||
await sendMessage(`Disabled all sound (sfx) channel point redemptions`, msg.messageId);
|
||||
return;
|
||||
};
|
||||
name: "disableRedeem",
|
||||
aliases: ["disableredeem"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: async (msg) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) {
|
||||
await sendMessage(
|
||||
"Please specify a point redemption to disable",
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (args[0] === "sfx" || args[0] === "sound") {
|
||||
sfxRedeems.forEach(async (redeem) => {
|
||||
const id = idMap.get(redeem.name);
|
||||
if (!id) {
|
||||
await sendMessage(
|
||||
`Failed to find the ID for redeem ${redeem.name}`,
|
||||
msg.messageId,
|
||||
);
|
||||
logger.err(`Failed to find the ID for ${redeem.name} while enabling`);
|
||||
return;
|
||||
}
|
||||
await disableRedeem(redeem, id);
|
||||
});
|
||||
await sendMessage(
|
||||
`Disabled all sound (sfx) channel point redemptions`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
const selection = namedRedeems.get(args[0]);
|
||||
if (!selection) { await sendMessage(`Redeem ${args[0]} doesn't exist. The internal names for redeems are here: https://github.com/qwerinope/qweribot#point-redeems`, msg.messageId); return; };
|
||||
const id = idMap.get(selection.name);
|
||||
await disableRedeem(selection, id!);
|
||||
await sendMessage(`The ${selection.name} point redeem is now disabled`, msg.messageId);
|
||||
}
|
||||
const selection = namedRedeems.get(args[0]);
|
||||
if (!selection) {
|
||||
await sendMessage(
|
||||
`Redeem ${args[0]} doesn't exist. The internal names for redeems are here: https://github.com/qwerinope/qweribot#point-redeems`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const id = idMap.get(selection.name);
|
||||
await disableRedeem(selection, id!);
|
||||
await sendMessage(
|
||||
`The ${selection.name} point redeem is now disabled`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,52 +1,81 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { changeBalance } from "lib/changeBalance";
|
||||
import User from "user";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import logger from "lib/logger";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'donate',
|
||||
aliases: ['donate'],
|
||||
usertype: 'chatter',
|
||||
execution: 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 = parseInt(args[1]);
|
||||
if (isNaN(amount) || amount < 1) { await sendMessage(`'${args[1]}' is not a valid amount`); return; };
|
||||
name: "donate",
|
||||
aliases: ["donate"],
|
||||
usertype: "chatter",
|
||||
execution: 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 = parseInt(args[1], 10);
|
||||
if (Number.isNaN(amount) || amount < 1) {
|
||||
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; };
|
||||
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 (itemlock)', msg.messageId); return; };
|
||||
if ((await user.itemLock()) || (await target.itemLock())) {
|
||||
await sendMessage("Cannot give qweribucks (itemlock)", msg.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
user.setLock(),
|
||||
target.setLock()
|
||||
]);
|
||||
await Promise.all([user.setLock(), target.setLock()]);
|
||||
|
||||
const data = await Promise.all([
|
||||
await changeBalance(target, targetRecord, amount),
|
||||
await changeBalance(user, userRecord, -amount)
|
||||
]);
|
||||
const data = await Promise.all([
|
||||
await changeBalance(target, targetRecord, amount),
|
||||
await changeBalance(user, userRecord, -amount),
|
||||
]);
|
||||
|
||||
if (data[0] !== false && data[1] !== false) {
|
||||
const { balance: newamount } = data[0];
|
||||
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}`);
|
||||
};
|
||||
if (data[0] !== false && data[1] !== false) {
|
||||
const { balance: newamount } = data[0];
|
||||
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()
|
||||
]);
|
||||
}
|
||||
await Promise.all([user.clearLock(), target.clearLock()]);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { namedcheers } from "cheers";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { namedcheers } from "cheers";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'enablecheer',
|
||||
aliases: ['enablecheer'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "enablecheer",
|
||||
aliases: ["enablecheer"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,20 +1,35 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import commands from "commands";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'enablecommand',
|
||||
aliases: ['enablecommand'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "enablecommand",
|
||||
aliases: ["enablecommand"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,29 +1,54 @@
|
||||
import { enableRedeem, idMap, namedRedeems, sfxRedeems } from "pointRedeems";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import logger from "lib/logger";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { enableRedeem, idMap, namedRedeems, sfxRedeems } from "pointRedeems";
|
||||
|
||||
export default new Command({
|
||||
name: 'enableRedeem',
|
||||
aliases: ['enableredeem'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: async msg => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) { await sendMessage("Please specify a point redemption to enable", msg.messageId); return; };
|
||||
if (args[0] === 'sfx' || args[0] === 'sound') {
|
||||
sfxRedeems.forEach(async redeem => {
|
||||
const id = idMap.get(redeem.name);
|
||||
if (!id) { await sendMessage(`Failed to find the ID for redeem ${redeem.name}`, msg.messageId); logger.err(`Failed to find the ID for ${redeem.name} while enabling`); return; };
|
||||
await enableRedeem(redeem, id);
|
||||
});
|
||||
await sendMessage(`Enabled all sound (sfx) channel point redemptions`, msg.messageId);
|
||||
return;
|
||||
};
|
||||
const selection = namedRedeems.get(args[0]);
|
||||
if (!selection) { await sendMessage(`Redeem ${args[0]} doesn't exist. The internal names for redeems are here: https://github.com/qwerinope/qweribot#point-redeems`, msg.messageId); return; };
|
||||
const id = idMap.get(selection.name);
|
||||
await enableRedeem(selection, id!);
|
||||
await sendMessage(`The ${selection.name} point redeem is now enabled`, msg.messageId);
|
||||
}
|
||||
name: "enableRedeem",
|
||||
aliases: ["enableredeem"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: async (msg) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0]) {
|
||||
await sendMessage(
|
||||
"Please specify a point redemption to enable",
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (args[0] === "sfx" || args[0] === "sound") {
|
||||
sfxRedeems.forEach(async (redeem) => {
|
||||
const id = idMap.get(redeem.name);
|
||||
if (!id) {
|
||||
await sendMessage(
|
||||
`Failed to find the ID for redeem ${redeem.name}`,
|
||||
msg.messageId,
|
||||
);
|
||||
logger.err(`Failed to find the ID for ${redeem.name} while enabling`);
|
||||
return;
|
||||
}
|
||||
await enableRedeem(redeem, id);
|
||||
});
|
||||
await sendMessage(
|
||||
`Enabled all sound (sfx) channel point redemptions`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const selection = namedRedeems.get(args[0]);
|
||||
if (!selection) {
|
||||
await sendMessage(
|
||||
`Redeem ${args[0]} doesn't exist. The internal names for redeems are here: https://github.com/qwerinope/qweribot#point-redeems`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const id = idMap.get(selection.name);
|
||||
await enableRedeem(selection, id!);
|
||||
await sendMessage(
|
||||
`The ${selection.name} point redeem is now enabled`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,13 +2,13 @@ import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { timeout } from "lib/timeout";
|
||||
|
||||
export default new Command({
|
||||
name: 'fakemodme',
|
||||
aliases: ['modme', 'mod'],
|
||||
usertype: 'chatter',
|
||||
execution: async (_msg, user) => {
|
||||
await Promise.all([
|
||||
timeout(user, "NO MODME", 60),
|
||||
sendMessage(`NO MODME COMMAND!!! UltraMad UltraMad UltraMad`)
|
||||
]);
|
||||
}
|
||||
name: "fakemodme",
|
||||
aliases: ["modme", "mod"],
|
||||
usertype: "chatter",
|
||||
execution: async (_msg, user) => {
|
||||
await Promise.all([
|
||||
timeout(user, "NO MODME", 60),
|
||||
sendMessage(`NO MODME COMMAND!!! UltraMad UltraMad UltraMad`),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,19 +1,22 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getAdmins } from "lib/admins";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'getadmins',
|
||||
aliases: ['getadmins'],
|
||||
usertype: 'chatter',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "getadmins",
|
||||
aliases: ["getadmins"],
|
||||
usertype: "chatter",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,17 +1,32 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'getbalance',
|
||||
aliases: ['getbalance', 'balance', 'qbucks', 'qweribucks', 'wallet', 'getwallet'],
|
||||
usertype: 'chatter',
|
||||
execution: 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);
|
||||
}
|
||||
name: "getbalance",
|
||||
aliases: [
|
||||
"getbalance",
|
||||
"balance",
|
||||
"qbucks",
|
||||
"qweribucks",
|
||||
"wallet",
|
||||
"getwallet",
|
||||
],
|
||||
usertype: "chatter",
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,39 +1,63 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { namedcheers } from "cheers";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { namedcheers } from "cheers";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'getcheers',
|
||||
aliases: ['getcheers', 'getcheer'],
|
||||
usertype: 'chatter',
|
||||
disableable: false,
|
||||
execution: 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[] = [];
|
||||
name: "getcheers",
|
||||
aliases: ["getcheers", "getcheer"],
|
||||
usertype: "chatter",
|
||||
disableable: false,
|
||||
execution: 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}`);
|
||||
};
|
||||
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);
|
||||
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}`);
|
||||
}
|
||||
|
||||
} 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);
|
||||
}
|
||||
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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,30 +1,51 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { basecommands } from "commands";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'getcommands',
|
||||
aliases: ['getcommands', 'getc', 'commands'],
|
||||
usertype: 'chatter',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "getcommands",
|
||||
aliases: ["getcommands", "getc", "commands"],
|
||||
usertype: "chatter",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,31 +1,42 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import items from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
import items from "items";
|
||||
|
||||
export default new Command({
|
||||
name: 'inventory',
|
||||
aliases: ['inv', 'inventory', 'pocket'],
|
||||
usertype: 'chatter',
|
||||
execution: 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;
|
||||
};
|
||||
name: "inventory",
|
||||
aliases: ["inv", "inventory", "pocket"],
|
||||
usertype: "chatter",
|
||||
execution: 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}`);
|
||||
};
|
||||
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);
|
||||
}
|
||||
if (messagedata.length === 0) {
|
||||
await sendMessage(`${target.displayName} has no items`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
await sendMessage(
|
||||
`Inventory of ${target.displayName}: ${messagedata.join(", ")}`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,17 +3,20 @@ import { getInvulns } from "lib/invuln";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'getinvulns',
|
||||
aliases: ['getinvulns'],
|
||||
usertype: 'chatter',
|
||||
disableable: false,
|
||||
execution: async msg => {
|
||||
const invulns = await getInvulns()
|
||||
const invulnnames: string[] = [];
|
||||
for (const id of invulns) {
|
||||
const invuln = await User.initUserId(id);
|
||||
invulnnames.push(invuln?.displayName!);
|
||||
};
|
||||
await sendMessage(`Current invulnerable chatters: ${invulnnames.join(', ')}`, msg.messageId);
|
||||
}
|
||||
name: "getinvulns",
|
||||
aliases: ["getinvulns"],
|
||||
usertype: "chatter",
|
||||
disableable: false,
|
||||
execution: async (msg) => {
|
||||
const invulns = await getInvulns();
|
||||
const invulnnames: string[] = [];
|
||||
for (const id of invulns) {
|
||||
const invuln = await User.initUserId(id);
|
||||
invulnnames.push(invuln?.displayName!);
|
||||
}
|
||||
await sendMessage(
|
||||
`Current invulnerable chatters: ${invulnnames.join(", ")}`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,103 +1,139 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { createGetLootRecord } from "db/dbGetLoot";
|
||||
import { getUserRecord, updateUserRecord } from "db/dbUser";
|
||||
import itemMap, { type inventory, type items } from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { buildTimeString } from "lib/dateManager";
|
||||
import { timeout } from "lib/timeout";
|
||||
import { isInvuln, removeInvuln } from "lib/invuln";
|
||||
import { redis } from "lib/redis";
|
||||
import { timeout } from "lib/timeout";
|
||||
import { streamerUsers } from "main";
|
||||
import { createGetLootRecord } from "db/dbGetLoot";
|
||||
import { playAlert } from "web/alerts/serverFunctions";
|
||||
|
||||
const COOLDOWN = 10 * 60; // 10 mins (s)
|
||||
|
||||
export default new Command({
|
||||
name: 'getloot',
|
||||
aliases: ['getloot', 'dig', 'loot', 'mine'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
if (!await redis.exists('streamIsLive')) { await sendMessage(`No loot while stream is offline`, msg.messageId); return; };
|
||||
if (await isInvuln(msg.chatterId) && !streamerUsers.includes(msg.chatterId)) { await sendMessage(`You're no longer an invuln because used a lootbox.`, msg.messageId); await removeInvuln(msg.chatterId); };
|
||||
if (await user.itemLock()) { await sendMessage(`Cannot get loot (itemlock)`, msg.messageId); return; };
|
||||
await user.setLock();
|
||||
const userData = await getUserRecord(user);
|
||||
const timeData = await redis.expiretime(`user:${user.id}:lootboxcooldown`) * 1000;
|
||||
if ((timeData) > Date.now()) {
|
||||
await user.clearLock();
|
||||
if (await user.greedy()) {
|
||||
await Promise.all([
|
||||
sendMessage(`${user.displayName} STOP BEING GREEDY!!! UltraMad UltraMad UltraMad`),
|
||||
timeout(user, `Wait ${buildTimeString(timeData, Date.now())} for another lootbox`, 60)
|
||||
]);
|
||||
return;
|
||||
} else {
|
||||
await Promise.all([
|
||||
user.setGreed(),
|
||||
sendMessage(`Wait ${buildTimeString(timeData, Date.now())} for another lootbox.`, msg.messageId)
|
||||
]);
|
||||
return;
|
||||
};
|
||||
};
|
||||
name: "getloot",
|
||||
aliases: ["getloot", "dig", "loot", "mine"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
if (!(await redis.exists("streamIsLive"))) {
|
||||
await sendMessage(`No loot while stream is offline`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
if (
|
||||
(await isInvuln(msg.chatterId)) &&
|
||||
!streamerUsers.includes(msg.chatterId)
|
||||
) {
|
||||
await sendMessage(
|
||||
`You're no longer an invuln because used a lootbox.`,
|
||||
msg.messageId,
|
||||
);
|
||||
await removeInvuln(msg.chatterId);
|
||||
}
|
||||
if (await user.itemLock()) {
|
||||
await sendMessage(`Cannot get loot (itemlock)`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
await user.setLock();
|
||||
const userData = await getUserRecord(user);
|
||||
const timeData =
|
||||
(await redis.expiretime(`user:${user.id}:lootboxcooldown`)) * 1000;
|
||||
if (timeData > Date.now()) {
|
||||
await user.clearLock();
|
||||
if (await user.greedy()) {
|
||||
await Promise.all([
|
||||
sendMessage(
|
||||
`${user.displayName} STOP BEING GREEDY!!! UltraMad UltraMad UltraMad`,
|
||||
),
|
||||
timeout(
|
||||
user,
|
||||
`Wait ${buildTimeString(timeData, Date.now())} for another lootbox`,
|
||||
60,
|
||||
),
|
||||
]);
|
||||
return;
|
||||
} else {
|
||||
await Promise.all([
|
||||
user.setGreed(),
|
||||
sendMessage(
|
||||
`Wait ${buildTimeString(timeData, Date.now())} for another lootbox.`,
|
||||
msg.messageId,
|
||||
),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
await user.clearGreed();
|
||||
await user.clearGreed();
|
||||
|
||||
await redis.set(`user:${user.id}:lootboxcooldown`, '1');
|
||||
await redis.expire(`user:${user.id}:lootboxcooldown`, COOLDOWN);
|
||||
await redis.set(`user:${user.id}:lootboxcooldown`, "1");
|
||||
await redis.expire(`user:${user.id}:lootboxcooldown`, COOLDOWN);
|
||||
|
||||
if (!await redis.exists(`user:${user.id}:subbed`) && Math.random() < 0.1) {
|
||||
await Promise.all([
|
||||
user.clearLock(),
|
||||
updateUserRecord(user, userData),
|
||||
timeout(user, "THE LOOTBOX WAS TRAPPED!!!", 60),
|
||||
sendMessage(`wybuh wybuh ${user.displayName.toUpperCase()} FOUND A TRAPPED LOOTBOX!!! wybuh wybuh`),
|
||||
playAlert({
|
||||
name: 'grenadeExplosion',
|
||||
user: 'trapped lootbox',
|
||||
target: user.displayName
|
||||
})
|
||||
]);
|
||||
return;
|
||||
};
|
||||
const gainedqbucks = Math.floor(Math.random() * 100) + 50; // range from 50 to 150
|
||||
userData.balance += gainedqbucks;
|
||||
if (
|
||||
!(await redis.exists(`user:${user.id}:subbed`)) &&
|
||||
Math.random() < 0.1
|
||||
) {
|
||||
await Promise.all([
|
||||
user.clearLock(),
|
||||
updateUserRecord(user, userData),
|
||||
timeout(user, "THE LOOTBOX WAS TRAPPED!!!", 60),
|
||||
sendMessage(
|
||||
`wybuh wybuh ${user.displayName.toUpperCase()} FOUND A TRAPPED LOOTBOX!!! wybuh wybuh`,
|
||||
),
|
||||
playAlert({
|
||||
name: "grenadeExplosion",
|
||||
user: "trapped lootbox",
|
||||
target: user.displayName,
|
||||
}),
|
||||
]);
|
||||
return;
|
||||
}
|
||||
const gainedqbucks = Math.floor(Math.random() * 100) + 50; // range from 50 to 150
|
||||
userData.balance += gainedqbucks;
|
||||
|
||||
const itemDiff: inventory = {
|
||||
grenade: 0,
|
||||
blaster: 0,
|
||||
tnt: 0,
|
||||
silverbullet: 0
|
||||
};
|
||||
const itemDiff: inventory = {
|
||||
grenade: 0,
|
||||
blaster: 0,
|
||||
tnt: 0,
|
||||
silverbullet: 0,
|
||||
};
|
||||
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (Math.floor(Math.random() * 5) === 0) itemDiff.grenade! += 1; // 1 in 5
|
||||
if (Math.floor(Math.random() * 5) === 0) itemDiff.blaster! += 1; // 1 in 5
|
||||
if (Math.floor(Math.random() * 50) === 0) itemDiff.tnt! += 1; // 1 in 50
|
||||
if (Math.floor(Math.random() * 50) === 0) itemDiff.silverbullet! += 1; // 1 in 50
|
||||
};
|
||||
for (let i = 0; i < 3; i++) {
|
||||
if (Math.floor(Math.random() * 5) === 0) itemDiff.grenade! += 1; // 1 in 5
|
||||
if (Math.floor(Math.random() * 5) === 0) itemDiff.blaster! += 1; // 1 in 5
|
||||
if (Math.floor(Math.random() * 50) === 0) itemDiff.tnt! += 1; // 1 in 50
|
||||
if (Math.floor(Math.random() * 50) === 0) itemDiff.silverbullet! += 1; // 1 in 50
|
||||
}
|
||||
|
||||
for (const [item, amount] of Object.entries(itemDiff) as [items, number][]) {
|
||||
if (userData.inventory[item]) userData.inventory[item] += amount;
|
||||
else userData.inventory[item] = amount;
|
||||
};
|
||||
for (const [item, amount] of Object.entries(itemDiff) as [
|
||||
items,
|
||||
number,
|
||||
][]) {
|
||||
if (userData.inventory[item]) userData.inventory[item] += amount;
|
||||
else userData.inventory[item] = amount;
|
||||
}
|
||||
|
||||
const itemstrings: string[] = [`${gainedqbucks} qbucks`];
|
||||
const itemstrings: string[] = [`${gainedqbucks} qbucks`];
|
||||
|
||||
for (const [item, amount] of Object.entries(itemDiff)) {
|
||||
if (amount === 0) continue;
|
||||
const selection = itemMap.get(item);
|
||||
if (!selection) continue;
|
||||
itemstrings.push(`${amount} ${selection.prettyName + (amount === 1 ? '' : selection.plural)}`);
|
||||
};
|
||||
for (const [item, amount] of Object.entries(itemDiff)) {
|
||||
if (amount === 0) continue;
|
||||
const selection = itemMap.get(item);
|
||||
if (!selection) continue;
|
||||
itemstrings.push(
|
||||
`${amount} ${selection.prettyName + (amount === 1 ? "" : selection.plural)}`,
|
||||
);
|
||||
}
|
||||
|
||||
const last = itemstrings.pop();
|
||||
const itemstring = itemstrings.length === 0 ? last : itemstrings.join(', ') + " and " + last;
|
||||
const message = `You got ${itemstring}`;
|
||||
const last = itemstrings.pop();
|
||||
const itemstring =
|
||||
itemstrings.length === 0 ? last : `${itemstrings.join(", ")} and ${last}`;
|
||||
const message = `You got ${itemstring}`;
|
||||
|
||||
await Promise.all([
|
||||
updateUserRecord(user, userData),
|
||||
sendMessage(message, msg.messageId),
|
||||
createGetLootRecord(user, gainedqbucks, itemDiff, 'getloot'),
|
||||
user.clearLock()
|
||||
]);
|
||||
}
|
||||
await Promise.all([
|
||||
updateUserRecord(user, userData),
|
||||
sendMessage(message, msg.messageId),
|
||||
createGetLootRecord(user, gainedqbucks, itemDiff, "getloot"),
|
||||
user.clearLock(),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,12 +1,14 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { itemObjectArray } from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
|
||||
export default new Command({
|
||||
name: 'getprices',
|
||||
aliases: ['getprices', 'prices', 'shop'],
|
||||
usertype: 'chatter',
|
||||
execution: async msg => {
|
||||
const txt = itemObjectArray.toSorted((a, b) => a.price - b.price).map(item => `${item.prettyName}: ${item.price}`);
|
||||
await sendMessage(`Prices: ${txt.join(' | ')}`, msg.messageId);
|
||||
}
|
||||
name: "getprices",
|
||||
aliases: ["getprices", "prices", "shop"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg) => {
|
||||
const txt = itemObjectArray
|
||||
.toSorted((a, b) => a.price - b.price)
|
||||
.map((item) => `${item.prettyName}: ${item.price}`);
|
||||
await sendMessage(`Prices: ${txt.join(" | ")}`, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,21 +1,42 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { buildTimeString } from "lib/dateManager";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
import { timeoutDuration } from "lib/timeout";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'gettimeout',
|
||||
aliases: ['gett', 'gettimeout', 'releasetime'],
|
||||
usertype: 'chatter',
|
||||
execution: 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 timeoutDuration(target);
|
||||
if (data === false) { await sendMessage(`Chatter ${target.displayName} isn't timed out`, msg.messageId); return; };
|
||||
if (data) { await sendMessage(`${target.displayName} is still timed out for ${buildTimeString(data * 1000, Date.now())}`, msg.messageId); return; };
|
||||
await sendMessage(`${target.displayName} is permanently banned`, msg.messageId);
|
||||
}
|
||||
name: "gettimeout",
|
||||
aliases: ["gett", "gettimeout", "releasetime"],
|
||||
usertype: "chatter",
|
||||
execution: 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 timeoutDuration(target);
|
||||
if (data === false) {
|
||||
await sendMessage(
|
||||
`Chatter ${target.displayName} isn't timed out`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
if (data) {
|
||||
await sendMessage(
|
||||
`${target.displayName} is still timed out for ${buildTimeString(data * 1000, Date.now())}`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
await sendMessage(
|
||||
`${target.displayName} is permanently banned`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,52 +1,87 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getUserRecord } from "db/dbUser";
|
||||
import items, { changeItemCount } from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import logger from "lib/logger";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
import logger from "lib/logger";
|
||||
|
||||
export default new Command({
|
||||
name: 'give',
|
||||
aliases: ['give'],
|
||||
usertype: 'chatter',
|
||||
execution: 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 = parseInt(args[2]);
|
||||
if (isNaN(amount) || amount < 1) { 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; };
|
||||
name: "give",
|
||||
aliases: ["give"],
|
||||
usertype: "chatter",
|
||||
execution: 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 = parseInt(args[2], 10);
|
||||
if (Number.isNaN(amount) || amount < 1) {
|
||||
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 (itemlock)', msg.messageId); return; };
|
||||
if ((await user.itemLock()) || (await target.itemLock())) {
|
||||
await sendMessage("Cannot give item (itemlock)", msg.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
await Promise.all([
|
||||
user.setLock(),
|
||||
target.setLock()
|
||||
]);
|
||||
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)
|
||||
]);
|
||||
const data = await Promise.all([
|
||||
await changeItemCount(target, targetRecord, item.name, amount),
|
||||
await changeItemCount(user, userRecord, item.name, -amount),
|
||||
]);
|
||||
|
||||
if (data[0] !== false && data[1] !== false) {
|
||||
const tempdata = data[0];
|
||||
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 ? "yes" : "no"}, donator success: ${data[1] !== false ? "yes" : "no"}`);
|
||||
};
|
||||
await user.clearLock();
|
||||
await target.clearLock();
|
||||
}
|
||||
if (data[0] !== false && data[1] !== false) {
|
||||
const tempdata = data[0];
|
||||
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 ? "yes" : "no"}, donator success: ${data[1] !== false ? "yes" : "no"}`,
|
||||
);
|
||||
}
|
||||
await user.clearLock();
|
||||
await target.clearLock();
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,30 +1,34 @@
|
||||
import { Command } from 'lib/commandUtils';
|
||||
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 specialAliasCommands = new Map<string, Command>; // This map has all special command/item aliases mapped to commands/items (just like commands map)
|
||||
const basecommands = new Map<string, Command>; // This map has all command names mapped to commands (one-to-one) (no items)
|
||||
import { readdir } from "node:fs/promises";
|
||||
import type { Command } from "lib/commandUtils";
|
||||
|
||||
const commands = new Map<string, Command>(); // This map has all command/item aliases mapped to commands/items (many-to-one)
|
||||
const specialAliasCommands = new Map<string, Command>(); // This map has all special command/item aliases mapped to commands/items (just like commands map)
|
||||
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
|
||||
};
|
||||
for (const alias of command.specialaliases) {
|
||||
specialAliasCommands.set(alias, command);
|
||||
};
|
||||
};
|
||||
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
|
||||
}
|
||||
for (const alias of command.specialaliases) {
|
||||
specialAliasCommands.set(alias, command);
|
||||
}
|
||||
}
|
||||
|
||||
import items, { specialAliasItems } 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
|
||||
};
|
||||
commands.set(name, item); // As Item is basically just Command but with more parameters, this should work fine
|
||||
}
|
||||
for (const [alias, item] of Array.from(specialAliasItems)) {
|
||||
specialAliasCommands.set(alias, item);
|
||||
};
|
||||
specialAliasCommands.set(alias, item);
|
||||
}
|
||||
|
||||
export default commands;
|
||||
export { specialAliasCommands, basecommands };
|
||||
|
||||
@@ -1,16 +1,28 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import items from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
|
||||
export default new Command({
|
||||
name: 'iteminfo',
|
||||
aliases: ['iteminfo', 'itemhelp', 'info'],
|
||||
usertype: 'chatter',
|
||||
execution: 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);
|
||||
}
|
||||
name: "iteminfo",
|
||||
aliases: ["iteminfo", "itemhelp", "info"],
|
||||
usertype: "chatter",
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,17 +3,29 @@ import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'itemlock',
|
||||
aliases: ['itemlock'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "itemlock",
|
||||
aliases: ["itemlock"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,36 +1,40 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getKDLeaderboard } from "db/dbUser";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import User from "user";
|
||||
|
||||
type KD = { user: User; kd: number; };
|
||||
type KD = { user: User; kd: number };
|
||||
|
||||
export default new Command({
|
||||
name: 'monthlykdleaderboard',
|
||||
aliases: ['monthlyleaderboard', 'kdleaderboard', 'leaderboard'],
|
||||
usertype: 'chatter',
|
||||
execution: async msg => {
|
||||
const monthdata = new Date().toISOString().slice(0, 7);
|
||||
name: "monthlykdleaderboard",
|
||||
aliases: ["monthlyleaderboard", "kdleaderboard", "leaderboard"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg) => {
|
||||
const monthdata = new Date().toISOString().slice(0, 7);
|
||||
|
||||
const rawKD = await getKDLeaderboard(monthdata);
|
||||
if (rawKD.length === 0) {
|
||||
await sendMessage(`No users on leaderboard yet!`, msg.messageId);
|
||||
return;
|
||||
};
|
||||
const rawKD = await getKDLeaderboard(monthdata);
|
||||
if (rawKD.length === 0) {
|
||||
await sendMessage(`No users on leaderboard yet!`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
const userKDs: KD[] = [];
|
||||
await Promise.all(rawKD.map(async userRecord => {
|
||||
const user = await User.initUserId(userRecord.userId.toString());
|
||||
if (!user) return;
|
||||
userKDs.push({ user, kd: userRecord.KD })
|
||||
}));
|
||||
const userKDs: KD[] = [];
|
||||
await Promise.all(
|
||||
rawKD.map(async (userRecord) => {
|
||||
const user = await User.initUserId(userRecord.userId.toString());
|
||||
if (!user) return;
|
||||
userKDs.push({ user, kd: userRecord.KD });
|
||||
}),
|
||||
);
|
||||
|
||||
userKDs.sort((a, b) => b.kd - a.kd);
|
||||
userKDs.sort((a, b) => b.kd - a.kd);
|
||||
|
||||
const txt: string[] = [];
|
||||
for (let i = 0; i < (userKDs.length < 10 ? userKDs.length : 10); i++) {
|
||||
txt.push(`${i + 1}. ${userKDs[i]?.user.displayName}: ${userKDs[i]?.kd.toFixed(2)}`);
|
||||
};
|
||||
const txt: string[] = [];
|
||||
for (let i = 0; i < (userKDs.length < 10 ? userKDs.length : 10); i++) {
|
||||
txt.push(
|
||||
`${i + 1}. ${userKDs[i]?.user.displayName}: ${userKDs[i]?.kd.toFixed(2)}`,
|
||||
);
|
||||
}
|
||||
|
||||
await sendMessage(`Monthly leaderboard: ${txt.join(' | ')}`, msg.messageId);
|
||||
}
|
||||
await sendMessage(`Monthly leaderboard: ${txt.join(" | ")}`, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,33 +1,45 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getTimeoutStats, getItemStats } from "lib/getStats";
|
||||
import { getItemStats, getTimeoutStats } from "lib/getStats";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'monthlystats',
|
||||
aliases: ['stats', 'monthlystats'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
let target: User | null = user;
|
||||
if (args[0]) {
|
||||
target = await User.initUsername(args[0]);
|
||||
if (!target) { await sendMessage(`User ${args[0]} doesn't exist!`, msg.messageId); return; };
|
||||
};
|
||||
name: "monthlystats",
|
||||
aliases: ["stats", "monthlystats"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
let target: User | null = user;
|
||||
if (args[0]) {
|
||||
target = await User.initUsername(args[0]);
|
||||
if (!target) {
|
||||
await sendMessage(`User ${args[0]} doesn't exist!`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
const [timeout, item] = await Promise.all([getTimeoutStats(target, true), getItemStats(target, true)]);
|
||||
if (!timeout || !item) { await sendMessage(`ERROR: Something went wrong!`, msg.messageId); return; };
|
||||
const [timeout, item] = await Promise.all([
|
||||
getTimeoutStats(target, true),
|
||||
getItemStats(target, true),
|
||||
]);
|
||||
if (!timeout || !item) {
|
||||
await sendMessage(`ERROR: Something went wrong!`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
|
||||
const KD = timeout.shot.blaster / timeout.hit.blaster;
|
||||
const KD = timeout.shot.blaster / timeout.hit.blaster;
|
||||
|
||||
await sendMessage(`
|
||||
await sendMessage(
|
||||
`
|
||||
This month: stats of ${target.displayName}:
|
||||
Users blasted: ${timeout.shot.blaster},
|
||||
Blasted by others: ${timeout.hit.blaster} (${isNaN(KD) ? 0 : KD.toFixed(2)} K/D).
|
||||
Blasted by others: ${timeout.hit.blaster} (${Number.isNaN(KD) ? 0 : KD.toFixed(2)} K/D).
|
||||
Grenades lobbed: ${item.grenade},
|
||||
TNT exploded: ${item.tnt}.
|
||||
Silver bullets fired: ${timeout.shot.silverbullet},
|
||||
Silver bullets taken: ${timeout.hit.silverbullet}.
|
||||
`, msg.messageId);
|
||||
}
|
||||
`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,25 +1,25 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { getBalanceLeaderboard } from "db/dbUser";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'qbucksleaderboard',
|
||||
aliases: ['qbucksleaderboard', 'baltop', 'moneyleaderboard'],
|
||||
usertype: 'chatter',
|
||||
execution: async msg => {
|
||||
const data = await getBalanceLeaderboard();
|
||||
if (!data) return;
|
||||
name: "qbucksleaderboard",
|
||||
aliases: ["qbucksleaderboard", "baltop", "moneyleaderboard"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg) => {
|
||||
const data = await getBalanceLeaderboard();
|
||||
if (!data) return;
|
||||
|
||||
let index = 1;
|
||||
const txt: string[] = [];
|
||||
for (const userRecord of data) {
|
||||
if (userRecord.balance === 0) continue;
|
||||
const user = await User.initUserId(userRecord.id.toString());
|
||||
if (!user) continue;
|
||||
txt.push(`${index}. ${user.displayName}: ${userRecord.balance}`);
|
||||
index++;
|
||||
};
|
||||
let index = 1;
|
||||
const txt: string[] = [];
|
||||
for (const userRecord of data) {
|
||||
if (userRecord.balance === 0) continue;
|
||||
const user = await User.initUserId(userRecord.id.toString());
|
||||
if (!user) continue;
|
||||
txt.push(`${index}. ${user.displayName}: ${userRecord.balance}`);
|
||||
index++;
|
||||
}
|
||||
|
||||
await sendMessage(`Balance leaderboard: ${txt.join(' | ')}`, msg.messageId);
|
||||
}
|
||||
await sendMessage(`Balance leaderboard: ${txt.join(" | ")}`, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,29 +4,40 @@ import { streamerId } from "main";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'racetime',
|
||||
aliases: ['racetime', 'raceroom'],
|
||||
usertype: 'chatter',
|
||||
execution: async msg => {
|
||||
try { // this might be some of the worst http code ever
|
||||
const streamer = await User.initUserId(streamerId);
|
||||
name: "racetime",
|
||||
aliases: ["racetime", "raceroom"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg) => {
|
||||
try {
|
||||
// this might be some of the worst http code ever
|
||||
const streamer = await User.initUserId(streamerId);
|
||||
|
||||
const races = await fetch(`https://racetime.gg/smr/data`).then(a => a.json() as any);
|
||||
if (races.current_races.length < 1) { await sendMessage(`No Super Metroid Randomizer races active`, msg.messageId); return; };
|
||||
const races = await fetch(`https://racetime.gg/smr/data`).then(
|
||||
(a) => a.json() as any,
|
||||
);
|
||||
if (races.current_races.length < 1) {
|
||||
await sendMessage(
|
||||
`No Super Metroid Randomizer races active`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
|
||||
for (const race of races.current_races) {
|
||||
const data = await fetch(`https://racetime.gg${race.data_url}`).then(a => a.json() as any);
|
||||
for (const racer of data.entrants) {
|
||||
if (racer.user.twitch_name === streamer?.username) {
|
||||
await sendMessage(`https://racetime.gg${data.url}`, msg.messageId);
|
||||
return;
|
||||
};
|
||||
};
|
||||
};
|
||||
await sendMessage('Streamer is not in a racetime race.', msg.messageId);
|
||||
} catch (err) {
|
||||
await sendMessage("Failed to get racetime status", msg.messageId);
|
||||
logger.err(err as string);
|
||||
};
|
||||
}
|
||||
for (const race of races.current_races) {
|
||||
const data = await fetch(`https://racetime.gg${race.data_url}`).then(
|
||||
(a) => a.json() as any,
|
||||
);
|
||||
for (const racer of data.entrants) {
|
||||
if (racer.user.twitch_name === streamer?.username) {
|
||||
await sendMessage(`https://racetime.gg${data.url}`, msg.messageId);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
await sendMessage("Streamer is not in a racetime race.", msg.messageId);
|
||||
} catch (err) {
|
||||
await sendMessage("Failed to get racetime status", msg.messageId);
|
||||
logger.err(err as string);
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -4,19 +4,19 @@ import { streamerId } from "main";
|
||||
import { playAlert } from "web/alerts/serverFunctions";
|
||||
|
||||
export default new Command({
|
||||
name: 'randomchatter',
|
||||
aliases: ['randomchatter'],
|
||||
usertype: 'moderator',
|
||||
execution: async (msg) => {
|
||||
const data = await api.chat.getChatters(streamerId).then(a => a.data);
|
||||
const target = data[Math.floor(Math.random() * data.length)];
|
||||
await playAlert({
|
||||
name: 'blastinRoulette',
|
||||
user: msg.chatterName,
|
||||
targets: data.map(a => a.userDisplayName),
|
||||
finaltarget: target?.userDisplayName
|
||||
});
|
||||
await new Promise((res, _) => setTimeout(res, 4000));
|
||||
await sendMessage(`${target?.userDisplayName}`, msg.messageId);
|
||||
}
|
||||
name: "randomchatter",
|
||||
aliases: ["randomchatter"],
|
||||
usertype: "moderator",
|
||||
execution: async (msg) => {
|
||||
const data = await api.chat.getChatters(streamerId).then((a) => a.data);
|
||||
const target = data[Math.floor(Math.random() * data.length)];
|
||||
await playAlert({
|
||||
name: "blastinRoulette",
|
||||
user: msg.chatterName,
|
||||
targets: data.map((a) => a.userDisplayName),
|
||||
finaltarget: target?.userDisplayName,
|
||||
});
|
||||
await new Promise((res, _) => setTimeout(res, 4000));
|
||||
await sendMessage(`${target?.userDisplayName}`, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,22 +1,39 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { streamerUsers } from "main";
|
||||
import { removeAdmin } from "lib/admins";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { streamerUsers } from "main";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'removeadmin',
|
||||
aliases: ['removeadmin'],
|
||||
usertype: 'streamer',
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
}
|
||||
name: "removeadmin",
|
||||
aliases: ["removeadmin"],
|
||||
usertype: "streamer",
|
||||
disableable: false,
|
||||
execution: 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);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,22 +1,38 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { streamerUsers } from "main";
|
||||
import { redis } from "lib/redis";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { redis } from "lib/redis";
|
||||
import { streamerUsers } from "main";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'removebot',
|
||||
aliases: ['removebot'],
|
||||
usertype: 'streamer',
|
||||
disableable: false,
|
||||
execution: 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(`Cannot change bot status of qweribot managed user`, msg.messageId); return; };
|
||||
const data = await redis.del(`user:${target.id}:bot`);
|
||||
if (data === 1) await sendMessage(`${target.displayName} is no longer a bot`, msg.messageId);
|
||||
else await sendMessage(`${target.displayName} isn't a bot`, msg.messageId);
|
||||
}
|
||||
name: "removebot",
|
||||
aliases: ["removebot"],
|
||||
usertype: "streamer",
|
||||
disableable: false,
|
||||
execution: 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(
|
||||
`Cannot change bot status of qweribot managed user`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const data = await redis.del(`user:${target.id}:bot`);
|
||||
if (data === 1)
|
||||
await sendMessage(
|
||||
`${target.displayName} is no longer a bot`,
|
||||
msg.messageId,
|
||||
);
|
||||
else await sendMessage(`${target.displayName} isn't a bot`, msg.messageId);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,22 +1,42 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { streamerUsers } from "main";
|
||||
import { removeInvuln } from "lib/invuln";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { streamerUsers } from "main";
|
||||
import User from "user";
|
||||
|
||||
export default new Command({
|
||||
name: 'removeinvuln',
|
||||
aliases: ['removeinvuln'],
|
||||
usertype: 'moderator',
|
||||
disableable: false,
|
||||
execution: 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 invulnerability from ${target.displayName} as they are managed by the bot program`, msg.messageId); return; };
|
||||
const data = await removeInvuln(target.id);
|
||||
if (data === 1) await sendMessage(`${target.displayName} is no longer invulnerable`, msg.messageId);
|
||||
else await sendMessage(`${target.displayName} isn't invulnerable`, msg.messageId);
|
||||
}
|
||||
name: "removeinvuln",
|
||||
aliases: ["removeinvuln"],
|
||||
usertype: "moderator",
|
||||
disableable: false,
|
||||
execution: 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 invulnerability from ${target.displayName} as they are managed by the bot program`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
const data = await removeInvuln(target.id);
|
||||
if (data === 1)
|
||||
await sendMessage(
|
||||
`${target.displayName} is no longer invulnerable`,
|
||||
msg.messageId,
|
||||
);
|
||||
else
|
||||
await sendMessage(
|
||||
`${target.displayName} isn't invulnerable`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -5,21 +5,24 @@ import { timeout } from "lib/timeout";
|
||||
const barrelCount = 6;
|
||||
|
||||
export default new Command({
|
||||
name: 'roulette',
|
||||
aliases: ['roulette'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
if (!await redis.exists('rouletteCount')) await redis.set('rouletteCount', "0");
|
||||
const currentChamber = Number(await redis.get('rouletteCount'));
|
||||
const shot = Math.random() < 1 / (barrelCount - currentChamber);
|
||||
if (!shot) await Promise.all([
|
||||
redis.incr('rouletteCount'),
|
||||
sendMessage("SWEAT Click SWEAT", msg.messageId)
|
||||
]);
|
||||
else await Promise.all([
|
||||
redis.set('rouletteCount', "0"),
|
||||
sendMessage("wybuh BANG!! wybuh"),
|
||||
timeout(user, "You lost at russian roulette!", 5 * 60)
|
||||
]);
|
||||
}
|
||||
name: "roulette",
|
||||
aliases: ["roulette"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
if (!(await redis.exists("rouletteCount")))
|
||||
await redis.set("rouletteCount", "0");
|
||||
const currentChamber = Number(await redis.get("rouletteCount"));
|
||||
const shot = Math.random() < 1 / (barrelCount - currentChamber);
|
||||
if (!shot)
|
||||
await Promise.all([
|
||||
redis.incr("rouletteCount"),
|
||||
sendMessage("SWEAT Click SWEAT", msg.messageId),
|
||||
]);
|
||||
else
|
||||
await Promise.all([
|
||||
redis.set("rouletteCount", "0"),
|
||||
sendMessage("wybuh BANG!! wybuh"),
|
||||
timeout(user, "You lost at russian roulette!", 5 * 60),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -2,23 +2,28 @@ import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { timeout } from "lib/timeout";
|
||||
|
||||
export default new Command({
|
||||
name: 'seiso',
|
||||
aliases: ['seiso'],
|
||||
usertype: 'chatter',
|
||||
execution: async (msg, user) => {
|
||||
const rand = Math.floor(Math.random() * 101);
|
||||
if (rand > 75) await sendMessage(`${rand}% seiso YAAAA`, msg.messageId);
|
||||
else if (rand === 67) await Promise.all([
|
||||
sendMessage(`KOKPEG 67 KOKPEG`),
|
||||
timeout(user, 'SIX SEVEN', 67)
|
||||
])
|
||||
else if (rand > 50) 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)
|
||||
]);
|
||||
}
|
||||
name: "seiso",
|
||||
aliases: ["seiso"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg, user) => {
|
||||
const rand = Math.floor(Math.random() * 101);
|
||||
if (rand > 75) await sendMessage(`${rand}% seiso YAAAA`, msg.messageId);
|
||||
else if (rand === 67)
|
||||
await Promise.all([
|
||||
sendMessage(`KOKPEG 67 KOKPEG`),
|
||||
timeout(user, "SIX SEVEN", 67),
|
||||
]);
|
||||
else if (rand > 50)
|
||||
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),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,28 +1,34 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { isAdmin } from "lib/admins";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'stacking',
|
||||
aliases: ['stacking'],
|
||||
usertype: 'chatter',
|
||||
disableable: false,
|
||||
execution: async msg => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0] || !await isAdmin(msg.chatterId)) { await sendMessage(`Timeout stacking is currently ${await redis.exists('timeoutStacking') ? "on" : "off"}`, msg.messageId); return; };
|
||||
// Only admins can reach this part of code
|
||||
switch (args[0]) {
|
||||
case 'enable':
|
||||
case 'on':
|
||||
await redis.set('timeoutStacking', '1');
|
||||
await sendMessage('Timeout stacking is now on')
|
||||
break;
|
||||
case 'disable':
|
||||
case 'off':
|
||||
await redis.del('timeoutStacking');
|
||||
await sendMessage('Timeout stacking is now off')
|
||||
break;
|
||||
};
|
||||
}
|
||||
name: "stacking",
|
||||
aliases: ["stacking"],
|
||||
usertype: "chatter",
|
||||
disableable: false,
|
||||
execution: async (msg) => {
|
||||
const args = parseCommandArgs(msg.messageText);
|
||||
if (!args[0] || !(await isAdmin(msg.chatterId))) {
|
||||
await sendMessage(
|
||||
`Timeout stacking is currently ${(await redis.exists("timeoutStacking")) ? "on" : "off"}`,
|
||||
msg.messageId,
|
||||
);
|
||||
return;
|
||||
}
|
||||
// Only admins can reach this part of code
|
||||
switch (args[0]) {
|
||||
case "enable":
|
||||
case "on":
|
||||
await redis.set("timeoutStacking", "1");
|
||||
await sendMessage("Timeout stacking is now on");
|
||||
break;
|
||||
case "disable":
|
||||
case "off":
|
||||
await redis.del("timeoutStacking");
|
||||
await sendMessage("Timeout stacking is now off");
|
||||
break;
|
||||
}
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,17 +1,26 @@
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { handleCheer } from "events/message";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import parseCommandArgs from "lib/parseCommandArgs";
|
||||
|
||||
export default new Command({
|
||||
name: 'testcheer',
|
||||
aliases: ['testcheer'],
|
||||
usertype: 'streamer',
|
||||
disableable: false,
|
||||
execution: 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(parseInt(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);
|
||||
}
|
||||
name: "testcheer",
|
||||
aliases: ["testcheer"],
|
||||
usertype: "streamer",
|
||||
disableable: false,
|
||||
execution: 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 (Number.isNaN(parseInt(args[0], 10))) {
|
||||
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);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,25 +1,56 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import items from "items";
|
||||
import { isInvuln, removeInvuln } from "lib/invuln";
|
||||
import { streamerUsers } from "main";
|
||||
import getloot from "commands/getloot";
|
||||
import items from "items";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { isInvuln, removeInvuln } from "lib/invuln";
|
||||
import { redis } from "lib/redis";
|
||||
import { streamerUsers } from "main";
|
||||
|
||||
export default new Command({
|
||||
name: 'use',
|
||||
aliases: ['use'],
|
||||
usertype: 'chatter',
|
||||
disableable: false,
|
||||
specialaliases: ['i'],
|
||||
execution: async (msg, user, specialargs) => {
|
||||
const messagequery = msg.messageText.trim().split(' ').slice(1); // This selects the item, so on "i blast mrockstar20" it would pick ["blast", "mrockstar20"]
|
||||
const silent = msg.messageText.toLowerCase().startsWith('i');
|
||||
if (!messagequery[0]) { if (!silent) { await sendMessage('Please specify an item you would like to use', msg.messageId); }; return; };
|
||||
const selection = items.get(messagequery[0].toLowerCase());
|
||||
if (messagequery[0].toLowerCase() === "lootbox") { await getloot.execute(msg, user); return; };
|
||||
if (!selection) { if (!silent) { 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; };
|
||||
if (await isInvuln(msg.chatterId) && !streamerUsers.includes(msg.chatterId)) { await sendMessage(`You're no longer an invuln because you used an item.`, msg.messageId); await removeInvuln(msg.chatterId); };
|
||||
await selection.execute(msg, user, specialargs);
|
||||
}
|
||||
name: "use",
|
||||
aliases: ["use"],
|
||||
usertype: "chatter",
|
||||
disableable: false,
|
||||
specialaliases: ["i"],
|
||||
execution: async (msg, user, specialargs) => {
|
||||
const messagequery = msg.messageText.trim().split(" ").slice(1); // This selects the item, so on "i blast mrockstar20" it would pick ["blast", "mrockstar20"]
|
||||
const silent = msg.messageText.toLowerCase().startsWith("i");
|
||||
if (!messagequery[0]) {
|
||||
if (!silent) {
|
||||
await sendMessage(
|
||||
"Please specify an item you would like to use",
|
||||
msg.messageId,
|
||||
);
|
||||
}
|
||||
return;
|
||||
}
|
||||
const selection = items.get(messagequery[0].toLowerCase());
|
||||
if (messagequery[0].toLowerCase() === "lootbox") {
|
||||
await getloot.execute(msg, user);
|
||||
return;
|
||||
}
|
||||
if (!selection) {
|
||||
if (!silent) {
|
||||
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;
|
||||
}
|
||||
if (
|
||||
(await isInvuln(msg.chatterId)) &&
|
||||
!streamerUsers.includes(msg.chatterId)
|
||||
) {
|
||||
await sendMessage(
|
||||
`You're no longer an invuln because you used an item.`,
|
||||
msg.messageId,
|
||||
);
|
||||
await removeInvuln(msg.chatterId);
|
||||
}
|
||||
await selection.execute(msg, user, specialargs);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -1,13 +1,16 @@
|
||||
import { redis } from "lib/redis";
|
||||
import { Command, sendMessage } from "lib/commandUtils";
|
||||
import { redis } from "lib/redis";
|
||||
|
||||
export default new Command({
|
||||
name: 'vulnchatters',
|
||||
aliases: ['vulnchatters', 'vulnc', 'vc'],
|
||||
usertype: 'chatter',
|
||||
execution: async msg => {
|
||||
const data = await redis.keys('user:*:vulnerable');
|
||||
const one = data.length === 1;
|
||||
await sendMessage(`There ${one ? 'is' : 'are'} ${data.length} vulnerable chatter${one ? '' : 's'}`, msg.messageId);
|
||||
}
|
||||
name: "vulnchatters",
|
||||
aliases: ["vulnchatters", "vulnc", "vc"],
|
||||
usertype: "chatter",
|
||||
execution: async (msg) => {
|
||||
const data = await redis.keys("user:*:vulnerable");
|
||||
const one = data.length === 1;
|
||||
await sendMessage(
|
||||
`There ${one ? "is" : "are"} ${data.length} vulnerable chatter${one ? "" : "s"}`,
|
||||
msg.messageId,
|
||||
);
|
||||
},
|
||||
});
|
||||
|
||||
@@ -3,22 +3,24 @@ import { timeout } from "lib/timeout";
|
||||
|
||||
// Remake of the !yabai command in ttv/kiara_tv
|
||||
export default new Command({
|
||||
name: 'yabai',
|
||||
aliases: ['yabai', 'goon'],
|
||||
usertype: 'chatter',
|
||||
execution: 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 === 67) await Promise.all([
|
||||
sendMessage(`KOKPEG 67 KOKPEG`),
|
||||
timeout(user, 'SIX SEVEN', 67)
|
||||
])
|
||||
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)
|
||||
]);
|
||||
}
|
||||
name: "yabai",
|
||||
aliases: ["yabai", "goon"],
|
||||
usertype: "chatter",
|
||||
execution: 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 === 67)
|
||||
await Promise.all([
|
||||
sendMessage(`KOKPEG 67 KOKPEG`),
|
||||
timeout(user, "SIX SEVEN", 67),
|
||||
]);
|
||||
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),
|
||||
]);
|
||||
},
|
||||
});
|
||||
|
||||
Reference in New Issue
Block a user