mirror of
https://gitlab.com/qwerinope/qweribot.git
synced 2026-02-04 06:26:59 +01:00
add economy command (so darkxoa for idea), streamer silverbullet doesn't get stored, minor blaster and silverbullet fixes
This commit is contained in:
@@ -170,6 +170,7 @@ COMMAND|FUNCTION|USER|ALIASES|DISABLEABLE
|
|||||||
`anivtimeouts`|Get the amount of timeouts, dodges and dodge percentage from aniv timeouts [(info)](#aniv-timeouts)|anyone|`anivtimeouts` `anivtimeout`|:white_check_mark:
|
`anivtimeouts`|Get the amount of timeouts, dodges and dodge percentage from aniv timeouts [(info)](#aniv-timeouts)|anyone|`anivtimeouts` `anivtimeout`|:white_check_mark:
|
||||||
`racetime`|Get the racetime.gg room the streamer is currently in. Needs to have twitch linked to racetime account|anyone|`racetime` `raceroom`|:white_check_mark:
|
`racetime`|Get the racetime.gg room the streamer is currently in. Needs to have twitch linked to racetime account|anyone|`racetime` `raceroom`|:white_check_mark:
|
||||||
`randomchatter`|Get a random chatter for whatever reason|moderators|`randomchatter`|:white_check_mark:
|
`randomchatter`|Get a random chatter for whatever reason|moderators|`randomchatter`|:white_check_mark:
|
||||||
|
`economy`|Get a count of all items in circulation|anyone|`economy` `eco`|:white_check_mark:
|
||||||
|
|
||||||
### Qweribucks/Item commands
|
### Qweribucks/Item commands
|
||||||
|
|
||||||
@@ -225,7 +226,7 @@ NAME|COMMAND|FUNCTION|ALIASES|COST
|
|||||||
-|-|-|-|-
|
-|-|-|-|-
|
||||||
Blaster|`blaster {target}`|Times targeted user out for 60 seconds|`blaster` `blast`|100
|
Blaster|`blaster {target}`|Times targeted user out for 60 seconds|`blaster` `blast`|100
|
||||||
Grenade|`grenade`|Times a random vulnerable chatter out for 60 seconds|`grenade`|99
|
Grenade|`grenade`|Times a random vulnerable chatter out for 60 seconds|`grenade`|99
|
||||||
Silver Bullet|`silverbullet [target]`|Times targeted or random vulnerable user out for 30 minutes|`silverbullet` `execute` `{blastin}`|666
|
Silver Bullet|`silverbullet [target]`|Times targeted or random vulnerable user out for 30 minutes|`silverbullet` `execute` `{blastin}` `{fuck}`|666
|
||||||
TNT|`tnt`|Give 5-10 random chatters 60 second timeouts|`tnt`|1000
|
TNT|`tnt`|Give 5-10 random chatters 60 second timeouts|`tnt`|1000
|
||||||
|
|
||||||
## Cheers
|
## Cheers
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
{
|
{
|
||||||
"$schema": "https://biomejs.dev/schemas/2.3.8/schema.json",
|
"$schema": "https://biomejs.dev/schemas/2.3.10/schema.json",
|
||||||
"vcs": {
|
"vcs": {
|
||||||
"enabled": true,
|
"enabled": true,
|
||||||
"clientKind": "git",
|
"clientKind": "git",
|
||||||
|
|||||||
22
src/commands/economy.ts
Normal file
22
src/commands/economy.ts
Normal file
@@ -0,0 +1,22 @@
|
|||||||
|
import { getTotalItemCounts } from "db/dbUser";
|
||||||
|
import itemAliasMap from "items";
|
||||||
|
import { Command, sendMessage } from "lib/commandUtils";
|
||||||
|
|
||||||
|
export default new Command({
|
||||||
|
name: "economy",
|
||||||
|
aliases: ["economy", "eco"],
|
||||||
|
usertype: "chatter",
|
||||||
|
execution: async (msg) => {
|
||||||
|
const allitems = await getTotalItemCounts();
|
||||||
|
const itemList = Object.entries(allitems)
|
||||||
|
.sort(([, a], [, b]) => b - a)
|
||||||
|
.map(([item, count]) => {
|
||||||
|
const itemobj = itemAliasMap.get(item);
|
||||||
|
if (itemobj) return `${itemobj.prettyName}: ${count}`;
|
||||||
|
return `${item}: ${count}`; // Fallback if an item doesn't have their name as an alias
|
||||||
|
})
|
||||||
|
.join(" | ");
|
||||||
|
|
||||||
|
await sendMessage(`Total Items in circulation: ${itemList}`, msg.messageId);
|
||||||
|
},
|
||||||
|
});
|
||||||
@@ -12,7 +12,8 @@ import {
|
|||||||
type SQL,
|
type SQL,
|
||||||
sql,
|
sql,
|
||||||
} from "drizzle-orm";
|
} from "drizzle-orm";
|
||||||
import { itemarray } from "items";
|
import { itemarray, type items } from "items";
|
||||||
|
import { ANIVNAMES } from "lib/handleAnivMessage";
|
||||||
import type User from "user";
|
import type User from "user";
|
||||||
|
|
||||||
/** Use this function to both ensure existance and to retreive data */
|
/** Use this function to both ensure existance and to retreive data */
|
||||||
@@ -120,3 +121,25 @@ export async function getKDLeaderboard(monthData?: string) {
|
|||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
type ItemCounts = Record<items, number>;
|
||||||
|
|
||||||
|
export async function getTotalItemCounts(): Promise<ItemCounts> {
|
||||||
|
const allUsers = await db
|
||||||
|
.select({ username: users.username, inventory: users.inventory })
|
||||||
|
.from(users);
|
||||||
|
|
||||||
|
const filteredUsers = allUsers.filter(
|
||||||
|
(user) =>
|
||||||
|
!Array.from<string>(ANIVNAMES).includes(user.username.toLowerCase()),
|
||||||
|
);
|
||||||
|
|
||||||
|
const counts = itemarray.reduce((acc, item) => {
|
||||||
|
acc[item] = filteredUsers.reduce((sum, user) => {
|
||||||
|
return sum + (user.inventory[item] || 0);
|
||||||
|
}, 0);
|
||||||
|
return acc;
|
||||||
|
}, {} as ItemCounts);
|
||||||
|
|
||||||
|
return counts;
|
||||||
|
}
|
||||||
|
|||||||
@@ -28,7 +28,7 @@ export default new Item({
|
|||||||
}
|
}
|
||||||
const target = await User.initUsername(messagequery[0].toLowerCase());
|
const target = await User.initUsername(messagequery[0].toLowerCase());
|
||||||
if (!target) {
|
if (!target) {
|
||||||
await sendMessage(`${messagequery[0]} doesn't exist`);
|
await sendMessage(`${messagequery[0]} doesn't exist`, msg.messageId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
await getUserRecord(target); // make sure the user record exist in the database
|
await getUserRecord(target); // make sure the user record exist in the database
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ export default new Item({
|
|||||||
plural: "s",
|
plural: "s",
|
||||||
description: "Times targeted or random vulnerable user out for 30 minutes",
|
description: "Times targeted or random vulnerable user out for 30 minutes",
|
||||||
aliases: ["execute", "silverbullet"],
|
aliases: ["execute", "silverbullet"],
|
||||||
specialaliases: ["blastin"],
|
specialaliases: ["blastin", "fuck"],
|
||||||
price: 666,
|
price: 666,
|
||||||
execution: async (msg, user, specialargs) => {
|
execution: async (msg, user, specialargs) => {
|
||||||
const messagequery = parseCommandArgs(
|
const messagequery = parseCommandArgs(
|
||||||
@@ -67,7 +67,7 @@ export default new Item({
|
|||||||
}
|
}
|
||||||
if (!target) {
|
if (!target) {
|
||||||
await user.clearLock();
|
await user.clearLock();
|
||||||
await sendMessage(`${messagequery[0]} doesn't exist`);
|
await sendMessage(`${messagequery[0]} doesn't exist`, msg.messageId);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -78,21 +78,25 @@ export default new Item({
|
|||||||
`You got blasted by ${user.displayName}!`,
|
`You got blasted by ${user.displayName}!`,
|
||||||
60 * 30,
|
60 * 30,
|
||||||
);
|
);
|
||||||
if (result.status)
|
if (result.status) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendMessage(
|
sendMessage(
|
||||||
`KEKPOINT KEKPOINT KEKPOINT ${target.displayName.toUpperCase()} RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO`,
|
`KEKPOINT KEKPOINT KEKPOINT ${target.displayName.toUpperCase()} RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO RIPBOZO`,
|
||||||
),
|
),
|
||||||
changeItemCount(user, userObj, ITEMNAME),
|
|
||||||
createTimeoutRecord(user, target, ITEMNAME),
|
|
||||||
createUsedItemRecord(user, ITEMNAME),
|
|
||||||
playAlert({
|
playAlert({
|
||||||
name: "userExecution",
|
name: "userExecution",
|
||||||
user: user.displayName,
|
user: user.displayName,
|
||||||
target: target.displayName,
|
target: target.displayName,
|
||||||
}),
|
}),
|
||||||
]);
|
]);
|
||||||
else {
|
if (user.id !== streamerId)
|
||||||
|
// streamer doesn't consume bullets and doesn't count for timeouts
|
||||||
|
await Promise.all([
|
||||||
|
changeItemCount(user, userObj, ITEMNAME),
|
||||||
|
createTimeoutRecord(user, target, ITEMNAME),
|
||||||
|
createUsedItemRecord(user, ITEMNAME),
|
||||||
|
]);
|
||||||
|
} else {
|
||||||
switch (result.reason) {
|
switch (result.reason) {
|
||||||
case "banned":
|
case "banned":
|
||||||
await sendMessage(
|
await sendMessage(
|
||||||
|
|||||||
Reference in New Issue
Block a user