mirror of
https://gitlab.com/qwerinope/qweribot.git
synced 2026-02-04 12:56:58 +01:00
Compare commits
2 Commits
55ad3d3b1c
...
253775a66e
| Author | SHA1 | Date | |
|---|---|---|---|
|
253775a66e
|
|||
|
d9c9f0c217
|
@@ -7,8 +7,9 @@ import { timeout } from "lib/timeout";
|
|||||||
import { isInvuln, removeInvuln } from "lib/invuln";
|
import { isInvuln, removeInvuln } from "lib/invuln";
|
||||||
import { streamerUsers } from "main";
|
import { streamerUsers } from "main";
|
||||||
import { createGetLootRecord } from "db/dbGetLoot";
|
import { createGetLootRecord } from "db/dbGetLoot";
|
||||||
|
import { playAlert } from "web/alerts/serverFunctions";
|
||||||
|
|
||||||
const COOLDOWN = 10 * 60 * 1000; // 10 mins (ms)
|
const COOLDOWN = 10 * 60; // 10 mins (s)
|
||||||
|
|
||||||
export default new Command({
|
export default new Command({
|
||||||
name: 'getloot',
|
name: 'getloot',
|
||||||
@@ -20,20 +21,19 @@ export default new Command({
|
|||||||
if (await user.itemLock()) { await sendMessage(`Cannot get loot (itemlock)`, msg.messageId); return; };
|
if (await user.itemLock()) { await sendMessage(`Cannot get loot (itemlock)`, msg.messageId); return; };
|
||||||
await user.setLock();
|
await user.setLock();
|
||||||
const userData = await getUserRecord(user);
|
const userData = await getUserRecord(user);
|
||||||
const lastlootbox = userData.lastlootbox.getTime();
|
const timeData = await redis.expiretime(`user:${user.id}:lootboxcooldown`) * 1000;
|
||||||
const now = Date.now();
|
if ((timeData) > Date.now()) {
|
||||||
if ((lastlootbox + COOLDOWN) > now) {
|
|
||||||
await user.clearLock();
|
await user.clearLock();
|
||||||
if (await user.greedy()) {
|
if (await user.greedy()) {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
sendMessage(`${user.displayName} STOP BEING GREEDY!!! UltraMad UltraMad UltraMad`),
|
sendMessage(`${user.displayName} STOP BEING GREEDY!!! UltraMad UltraMad UltraMad`),
|
||||||
timeout(user, `Wait ${buildTimeString(now - COOLDOWN, lastlootbox)}`, 60)
|
timeout(user, `Wait ${buildTimeString(timeData, Date.now())} for another lootbox`, 60)
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
} else {
|
} else {
|
||||||
await Promise.all([
|
await Promise.all([
|
||||||
user.setGreed(),
|
user.setGreed(),
|
||||||
sendMessage(`Wait ${buildTimeString(now - COOLDOWN, lastlootbox)} for another lootbox.`, msg.messageId)
|
sendMessage(`Wait ${buildTimeString(timeData, Date.now())} for another lootbox.`, msg.messageId)
|
||||||
]);
|
]);
|
||||||
return;
|
return;
|
||||||
};
|
};
|
||||||
@@ -41,8 +41,23 @@ export default new Command({
|
|||||||
|
|
||||||
await user.clearGreed();
|
await user.clearGreed();
|
||||||
|
|
||||||
userData.lastlootbox = new Date(now);
|
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
|
const gainedqbucks = Math.floor(Math.random() * 100) + 50; // range from 50 to 150
|
||||||
userData.balance += gainedqbucks;
|
userData.balance += gainedqbucks;
|
||||||
|
|
||||||
|
|||||||
@@ -8,6 +8,10 @@ export default new Command({
|
|||||||
execution: async (msg, user) => {
|
execution: async (msg, user) => {
|
||||||
const rand = Math.floor(Math.random() * 101);
|
const rand = Math.floor(Math.random() * 101);
|
||||||
if (rand > 75) await sendMessage(`${rand}% seiso YAAAA`, msg.messageId);
|
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 POGGERS`, msg.messageId);
|
||||||
else if (rand === 50) await sendMessage(`${rand}% seiso ok`, 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 > 30) await sendMessage(`${rand}% seiso SWEAT`, msg.messageId);
|
||||||
|
|||||||
@@ -11,6 +11,10 @@ export default new Command({
|
|||||||
if (rand < 25) sendMessage(`${rand}% yabai! GIGACHAD`, msg.messageId);
|
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 POGGERS`, msg.messageId);
|
||||||
else if (rand === 50) sendMessage(`${rand}% yabai ok`, 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 if (rand < 90) sendMessage(`${rand}% yabai AINTNOWAY`, msg.messageId);
|
||||||
else await Promise.all([
|
else await Promise.all([
|
||||||
sendMessage(`${msg.chatterDisplayName} is ${rand}% yabai CAUGHT`),
|
sendMessage(`${msg.chatterDisplayName} is ${rand}% yabai CAUGHT`),
|
||||||
|
|||||||
@@ -13,8 +13,7 @@ export const users = pgTable('users', {
|
|||||||
id: integer().primaryKey().notNull(),
|
id: integer().primaryKey().notNull(),
|
||||||
username: varchar().notNull(),
|
username: varchar().notNull(),
|
||||||
balance: integer().default(0).notNull(),
|
balance: integer().default(0).notNull(),
|
||||||
inventory: jsonb().$type<inventory>().default({}).notNull(),
|
inventory: jsonb().$type<inventory>().default({}).notNull()
|
||||||
lastlootbox: timestamp().default(new Date(0)).notNull()
|
|
||||||
});
|
});
|
||||||
|
|
||||||
export const usersRelations = relations(users, ({ many }) => ({
|
export const usersRelations = relations(users, ({ many }) => ({
|
||||||
|
|||||||
@@ -117,7 +117,8 @@ for (const sub of subs) {
|
|||||||
redisSubs.map(async a => await redis.del(`user:${a}:subbed`));
|
redisSubs.map(async a => await redis.del(`user:${a}:subbed`));
|
||||||
|
|
||||||
const streamdata = await api.streams.getStreamByUserId(streamerId);
|
const streamdata = await api.streams.getStreamByUserId(streamerId);
|
||||||
if (streamdata) await redis.set('streamIsLive', '1');
|
if (streamdata) await redis.set('streamIsLive', '1')
|
||||||
|
else await redis.del('streamIsLive');
|
||||||
|
|
||||||
await import("./events");
|
await import("./events");
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user