forked from cosmic/scythe
feat: insta and bump
This commit is contained in:
parent
88ad4744ae
commit
b09e71a591
|
|
@ -32,3 +32,5 @@ report.[0-9]_.[0-9]_.[0-9]_.[0-9]_.json
|
|||
|
||||
# Finder (MacOS) folder config
|
||||
.DS_Store
|
||||
|
||||
bump.json
|
||||
|
|
@ -6,5 +6,6 @@ module "bun" {
|
|||
GUILD: string;
|
||||
BAD_ROLE: string;
|
||||
BOT_ROLE: string;
|
||||
BOT_CHANNEL: string;
|
||||
}
|
||||
}
|
||||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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;
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
Loading…
Reference in New Issue