forked from cosmic/scythe
1
0
Fork 0

feat: insta and bump

This commit is contained in:
rainydevzz 2025-03-19 23:58:12 -07:00
parent 88ad4744ae
commit b09e71a591
5 changed files with 48 additions and 6 deletions

2
.gitignore vendored
View File

@ -32,3 +32,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
# Finder (MacOS) folder config
.DS_Store
bump.json

1
env.d.ts vendored
View File

@ -6,5 +6,6 @@ module "bun" {
GUILD: string;
BAD_ROLE: string;
BOT_ROLE: string;
BOT_CHANNEL: string;
}
}

View File

@ -1,6 +1,7 @@
import { Discord, On, type ArgsOf } from "discordx";
import { Client, Discord, On, type ArgsOf } from "discordx";
import { snipeObject } from "..";
import { sleep } from "../utils/underage";
import { bumpRemind } from "../utils/bump";
@Discord()
export class MessageEvents {
@ -10,14 +11,27 @@ export class MessageEvents {
snipeObject.content = msg.content;
}
@On({ event: "messageCreate" })
async messageCreate([msg]: ArgsOf<"messageCreate">) {
async messageCreate([msg]: ArgsOf<"messageCreate">, client: Client) {
if (msg.author.id == msg.client.user.id) return;
const linkRegex = /instagram\.com\/([^\s?]+)/;
if (linkRegex.test(msg.content)) {
let fixedLink = msg.content.match(linkRegex);
if (fixedLink) {
const linkMsg = fixedLink[0]
.replace("instagram.com/", "insta.ananas.moe/")
.replace("www.instagram.com/", "insta.ananas.moe/");
await msg.channel.send("https://" + linkMsg);
await msg.suppressEmbeds();
}
}
if (msg.embeds.length > 0) {
if (msg.embeds[0].description?.includes("Bump done!")) {
await msg.channel.send(
"thanks for bumping <3 I'll send a reminder in 2 hours :3",
);
await sleep(1000 * 60 * 120);
await msg.channel.send("it's time to bump again!");
const f = Bun.file("bump.json");
await f.write(JSON.stringify({ bump: Date.now() }));
bumpRemind(client);
}
}
}

View File

@ -1,5 +1,6 @@
import { Client, Discord, On, type ArgsOf } from "discordx";
import { underageCheck } from "../utils/underage";
import { bumpRemind } from "../utils/bump";
@Discord()
export class Ready {
@ -9,8 +10,12 @@ export class Ready {
await client.initApplicationCommands();
await client.guilds.fetch();
const members = client.guilds.cache.get(Bun.env.GUILD!)?.members;
if (!(await Bun.file("bump.json").exists())) {
await Bun.write("bump.json", "{}");
}
if (members) {
await underageCheck(members);
}
underageCheck(members);
}
bumpRemind(client);
}
}

20
src/utils/bump.ts Normal file
View File

@ -0,0 +1,20 @@
import type { Client } from "discordx";
import type { TextChannel } from "discord.js";
import { sleep } from "./underage";
export const bumpRemind = async (client: Client) => {
while (true) {
await sleep(5000);
const f = await Bun.file("bump.json").text();
const data = JSON.parse(f);
if (data["bump"]) {
if (Date.now() - data["bump"] >= 60 * 120) {
const channel = client.channels.cache.get(
Bun.env.BOT_CHANNEL,
) as TextChannel;
await channel.send("it's time to bump again!");
return;
}
}
}
};