Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: annoying tax #1660

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 2 additions & 0 deletions prisma/migrations/20241121220919_annoying/migration.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,2 @@
-- AlterTable
ALTER TABLE "Economy" ADD COLUMN "annoying" BOOLEAN NOT NULL DEFAULT false;
1 change: 1 addition & 0 deletions prisma/schema.prisma
Original file line number Diff line number Diff line change
Expand Up @@ -176,6 +176,7 @@ model Economy {
defaultBet Int?
padlock Boolean @default(false)
passive Boolean @default(false)
annoying Boolean @default(false)

xp BigInt @default(0)
level Int @default(0)
Expand Down
4 changes: 4 additions & 0 deletions src/commands/rob.ts
Original file line number Diff line number Diff line change
Expand Up @@ -30,6 +30,7 @@ import { isUserBlacklisted } from "../utils/functions/users/blacklist";
import { getDmSettings } from "../utils/functions/users/notifications";
import { addCooldown, getResponse, onCooldown } from "../utils/handlers/cooldownhandler";
import ms = require("ms");
import { isAnnoying } from "../utils/functions/economy/annoying";

const playerCooldown = new Set<string>();

Expand Down Expand Up @@ -176,6 +177,9 @@ async function run(
if (await isPassive(message.member))
return send({ embeds: [new ErrorEmbed("you are currently in passive mode")] });

if (await isAnnoying(message.member))
return send({ embeds: [new ErrorEmbed("if you werent so annoying you could rob other people")] });

const targetGuild = await getGuildByUser(target);

if (targetGuild) {
Expand Down
23 changes: 23 additions & 0 deletions src/commands/x.ts
Original file line number Diff line number Diff line change
Expand Up @@ -48,6 +48,7 @@
import { addTag, getTags, removeTag } from "../utils/functions/users/tags";
import { hasProfile } from "../utils/functions/users/utils";
import { logger } from "../utils/logger";
import { isAnnoying, setAnnoying } from "../utils/functions/economy/annoying";

const cmd = new Command("x", "admincmd", "none").setPermissions(["bot owner"]);

Expand Down Expand Up @@ -1515,7 +1516,7 @@
return message.channel.send({ embeds: [new CustomEmbed(message.member, desc)] });
};

const requestProfileTransfer = async (from: User, to: User, force = false) => {

Check warning on line 1519 in src/commands/x.ts

View workflow job for this annotation

GitHub Actions / linting

'force' is assigned a value but never used
if ((await getAdminLevel(message.author.id)) !== 69)
return message.channel.send({
embeds: [new ErrorEmbed("lol xd xdxddxd ahahhaha YOURE GAY dont even TRY")],
Expand Down Expand Up @@ -1592,6 +1593,28 @@
}

return findId(args.slice(1, args.length).join(" "));
} else if (args[0].toLowerCase() == "thisguysannoying") {
if ((await getAdminLevel(message.author.id)) < 3) {
return message.channel.send({
embeds: [new ErrorEmbed("you require admin level **3** to do this")],
});
}
if (args.length == 1) {
return message.channel.send({ embeds: [new ErrorEmbed("who the hell is the annoying one? its probably you isnt it")] });
}

const user = await message.client.users.fetch(args[1]).catch(() => null);

if (!user) {
return message.channel.send({ embeds: [new ErrorEmbed("invalid user")] });
}

await setAnnoying(args[1], !await isAnnoying(args[1]));

return message.channel.send({
embeds: [new CustomEmbed(message.member, `${user.username} is ${await isAnnoying(args[1]) ? "now" : "no longer"} annoying`)]
});

} else if (args[0].toLowerCase() === "transfer") {
if (message.author.id !== Constants.TEKOH_ID) return;

Expand Down
1 change: 1 addition & 0 deletions src/utils/Constants.ts
Original file line number Diff line number Diff line change
Expand Up @@ -100,6 +100,7 @@ export default {
NETWORTH: "cache:economy:networth",
PADLOCK: "cache:economy:padlock",
PASSIVE: "cache:economy:passive",
ANNOYING: "cache:economy:annoying",
PRESTIGE: "cache:economy:prestige",
VOTE: "cache:economy:vote",
XP: "cache:economy:xp",
Expand Down
57 changes: 57 additions & 0 deletions src/utils/functions/economy/annoying.ts
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
import { GuildMember } from "discord.js";
import prisma from "../../../init/database";
import redis from "../../../init/redis";
import Constants from "../../Constants";
import ms = require("ms");

export async function isAnnoying(member: GuildMember | string) {
let id: string;
if (member instanceof GuildMember) {
id = member.user.id;
} else {
id = member;
}

const cache = await redis.get(`${Constants.redis.cache.economy.ANNOYING}:${id}`);

if (cache) {
return cache == "t";
}

const query = await prisma.economy.findUnique({
where: {
userId: id,
},
select: {
annoying: true,
},
});

await redis.set(`${Constants.redis.cache.economy.ANNOYING}:${id}`, query.annoying ? "t" : "f");
await redis.expire(
`${Constants.redis.cache.economy.ANNOYING}:${id}`,
Math.floor(ms("6 hours") / 1000),
);

return query.annoying;
}

export async function setAnnoying(member: GuildMember | string, value: boolean) {
let id: string;
if (member instanceof GuildMember) {
id = member.user.id;
} else {
id = member;
}

await prisma.economy.update({
where: {
userId: id,
},
data: {
annoying: value,
},
});

await redis.del(`${Constants.redis.cache.economy.ANNOYING}:${id}`);
}
11 changes: 11 additions & 0 deletions src/utils/functions/economy/bakery.ts
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ import { isPassive } from "./passive";
import { addTaskProgress } from "./tasks";
import { getBakeryUpgradesData, getItems, getUpgradesData } from "./utils";
import ms = require("ms");
import { isAnnoying } from "./annoying";

async function getLastBake(member: GuildMember | string) {
let id: string;
Expand Down Expand Up @@ -191,6 +192,16 @@ export async function runBakery(member: GuildMember) {
if (click[1] > 100) click[1] -= 10;
}

if (await isAnnoying(member)) {
click[1] -= 2;

if (click[1] > 10) click[1] -= 5;
if (click[1] > 30) click[1] -= 5;
if (click[1] > 50) click[1] -= 5;
if (click[1] > 100) click[1] *= 0.75;
if (click[1] > 100) click[1] -= 10;
}

if (passive > 0) {
await prisma.economy.update({
where: {
Expand Down
16 changes: 15 additions & 1 deletion src/utils/functions/economy/balance.ts
Original file line number Diff line number Diff line change
Expand Up @@ -22,6 +22,7 @@ import { hasVoted } from "./vote";
import { calcWorkerValues } from "./workers";
import ms = require("ms");
import _ = require("lodash");
import { isAnnoying } from "./annoying";

export async function getBalance(member: GuildMember | string) {
let id: string;
Expand Down Expand Up @@ -259,6 +260,7 @@ export async function getGambleMulti(member: GuildMember | string) {
boosters,
guildUpgrades,
passive,
annoying,
dmSettings,
inventory,
tier,
Expand All @@ -269,6 +271,7 @@ export async function getGambleMulti(member: GuildMember | string) {
getBoosters(id),
getGuildUpgradesByUser(member),
isPassive(id),
isAnnoying(id),
getDmSettings(id),
getInventory(id),
getTier(id),
Expand Down Expand Up @@ -339,6 +342,11 @@ export async function getGambleMulti(member: GuildMember | string) {
breakdownMap.set("passive", -3);
}

if (annoying) {
multi -= 5;
breakdownMap.set("annoying", -5);
}

const beforeBoosters = multi;

for (const boosterId of boosters.keys()) {
Expand Down Expand Up @@ -396,14 +404,15 @@ export async function getSellMulti(member: GuildMember | string) {
id = member;
}

const [level, tier, booster, boosters, guildUpgrades, passive, inventory, upgrades] =
const [level, tier, booster, boosters, guildUpgrades, passive, annoying, inventory, upgrades] =
await Promise.all([
getRawLevel(member),
getTier(member),
isBooster(id),
getBoosters(id),
getGuildUpgradesByUser(member),
isPassive(member),
isAnnoying(member),
getInventory(member),
getUpgrades(member),
]);
Expand Down Expand Up @@ -472,6 +481,11 @@ export async function getSellMulti(member: GuildMember | string) {
breakdown.set("passive", -5);
}

if (annoying) {
multi -= 7;
breakdown.set("annoying", -7);
}

const beforeBoosters = multi;

for (const boosterId of boosters.keys()) {
Expand Down
Loading