Skip to content

Commit 5191b42

Browse files
committed
Bump system addition, let's see if this will work on here, if it does then i will work it for a multi guild system for v3, or v2.4....
1 parent 081030f commit 5191b42

2 files changed

Lines changed: 123 additions & 0 deletions

File tree

Lines changed: 110 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,110 @@
1+
const fs = require("fs");
2+
3+
const DISBOARD_ID = "302050872383242240";
4+
const BUMP_COOLDOWN = 2 * 60 * 60 * 1000; // 2 hours in ms
5+
const CONFIG_FILE = "./bump-config.json";
6+
7+
// In-memory store: guildId -> { channelId, roleId, timer }
8+
const guildConfig = new Map();
9+
10+
// ─── Persistence ────────────────────────────────────────────────────────────
11+
12+
function loadConfig() {
13+
if (!fs.existsSync(CONFIG_FILE)) return;
14+
try {
15+
const data = JSON.parse(fs.readFileSync(CONFIG_FILE, "utf8"));
16+
for (const [guildId, config] of Object.entries(data)) {
17+
guildConfig.set(guildId, { ...config, timer: null });
18+
}
19+
console.log(`[BumpReminder] Loaded config for ${guildConfig.size} guild(s).`);
20+
} catch (err) {
21+
console.error("[BumpReminder] Failed to load config:", err);
22+
}
23+
}
24+
25+
function saveConfig() {
26+
const data = {};
27+
for (const [guildId, config] of guildConfig.entries()) {
28+
data[guildId] = { channelId: config.channelId, roleId: config.roleId };
29+
}
30+
fs.writeFileSync(CONFIG_FILE, JSON.stringify(data, null, 2));
31+
}
32+
33+
// ─── Setup ──────────────────────────────────────────────────────────────────
34+
35+
function setupBumpReminder(guildId, channelId, roleId) {
36+
const existing = guildConfig.get(guildId);
37+
if (existing?.timer) clearTimeout(existing.timer);
38+
39+
guildConfig.set(guildId, { channelId, roleId, timer: null });
40+
saveConfig();
41+
}
42+
43+
function removeBumpReminder(guildId) {
44+
const existing = guildConfig.get(guildId);
45+
if (existing?.timer) clearTimeout(existing.timer);
46+
guildConfig.delete(guildId);
47+
saveConfig();
48+
}
49+
50+
function getConfig(guildId) {
51+
return guildConfig.get(guildId) ?? null;
52+
}
53+
54+
// ─── Message Handler ─────────────────────────────────────────────────────────
55+
56+
async function handleMessage(message) {
57+
// Only care about DISBOARD messages in guilds
58+
if (message.author.id !== DISBOARD_ID) return;
59+
if (!message.guild) return;
60+
if (!message.embeds.length) return;
61+
62+
const embed = message.embeds[0];
63+
const isBumpSuccess = embed.description?.includes("Bump done");
64+
if (!isBumpSuccess) return;
65+
66+
const config = guildConfig.get(message.guild.id);
67+
if (!config) return;
68+
69+
// Clear any old pending timer
70+
if (config.timer) clearTimeout(config.timer);
71+
72+
// Send confirmation
73+
const channel = message.guild.channels.cache.get(config.channelId);
74+
if (!channel) return;
75+
76+
await channel
77+
.send({
78+
embeds: [
79+
{
80+
color: 0x57f287, // green
81+
description: "✅ **Server bumped!** I'll remind you when it's time to bump again.",
82+
footer: { text: "Reminder in 2 hours" },
83+
timestamp: new Date(Date.now() + BUMP_COOLDOWN).toISOString(),
84+
},
85+
],
86+
})
87+
.catch(() => {});
88+
89+
// Schedule reminder
90+
config.timer = setTimeout(async () => {
91+
const rolePing = config.roleId ? `<@&${config.roleId}>` : "";
92+
await channel
93+
.send({
94+
content: rolePing || null,
95+
embeds: [
96+
{
97+
color: 0xfee75c, // yellow
98+
title: "⏰ Time to bump the server!",
99+
description: "Run </bump:947088344167366698> to keep us at the top of **DISBOARD**.",
100+
footer: { text: "Bump now to bring in new members!" },
101+
},
102+
],
103+
})
104+
.catch(() => {});
105+
106+
config.timer = null;
107+
}, BUMP_COOLDOWN);
108+
}
109+
110+
module.exports = { loadConfig, setupBumpReminder, removeBumpReminder, getConfig, handleMessage };

index.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,19 @@ client.cooldowns = new Map();
4040
client.helpers = { checkPermissions };
4141
module.exports = client;
4242

43+
const { setupBumpReminder, handleMessage } = require("./bumpReminder");
44+
45+
// Example: configure on startup (or from a slash command)
46+
setupBumpReminder(
47+
"1392910932740538540",
48+
"1467685229916455013",
49+
"1467684301280907412" // the role to ping, e.g. @Bump Squad
50+
);
51+
52+
client.on("messageCreate", (message) => {
53+
handleMessage(client, message);
54+
});
55+
4356
async function InteractionHandler(interaction, type) {
4457
// Resolve the collection where this component/command should live
4558
const id = interaction.customId ?? interaction.commandName;

0 commit comments

Comments
 (0)