Skip to content

Commit d33e982

Browse files
committed
fix achievement config
1 parent 8f3ab90 commit d33e982

File tree

3 files changed

+83
-70
lines changed

3 files changed

+83
-70
lines changed

src/config.type.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,8 +3,6 @@ import type { InformationMessage } from "./modules/information/information.js";
33
import type { BrandingConfig } from "./util/branding.js";
44

55
export interface AchievementsConfig {
6-
/** Where to send achievement notifications */
7-
notificationMode: "channel" | "dm" | "trigger";
86
/** Dedicated channel for notifications (required if mode is "channel") */
97
notificationChannel?: string;
108
/** Fallback channel if trigger location unavailable (for "trigger" mode) */

src/modules/achievements/achievementDefinitions.ts

Lines changed: 83 additions & 65 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,11 @@ export interface AchievementContext {
2525
}
2626

2727
/** Notification mode for achievements */
28-
export type NotificationMode = "channel" | "dm" | "trigger";
28+
export type NotificationMode =
29+
| "channel" // Notify in a designated channel
30+
| "dm" // Notify the user via direct message when the achievement is earned
31+
| "trigger" // Notify in the channel where the achievement was triggered
32+
| "silent"; // Do not send any notification
2933

3034
export interface AchievementDefinition {
3135
id: string;
@@ -55,6 +59,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
5559
category: "bump",
5660
trigger: { type: "bump", event: "bump_recorded" },
5761
checkCondition: (ctx) => (ctx.totalBumps ?? 0) >= 1,
62+
notificationMode: "trigger",
5863
},
5964
{
6065
id: "bump_10",
@@ -64,6 +69,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
6469
category: "bump",
6570
trigger: { type: "bump", event: "bump_recorded" },
6671
checkCondition: (ctx) => (ctx.totalBumps ?? 0) >= 10,
72+
notificationMode: "trigger",
6773
},
6874
{
6975
id: "bump_50",
@@ -73,6 +79,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
7379
category: "bump",
7480
trigger: { type: "bump", event: "bump_recorded" },
7581
checkCondition: (ctx) => (ctx.totalBumps ?? 0) >= 50,
82+
notificationMode: "trigger",
7683
},
7784
{
7885
id: "bump_100",
@@ -82,6 +89,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
8289
category: "bump",
8390
trigger: { type: "bump", event: "bump_recorded" },
8491
checkCondition: (ctx) => (ctx.totalBumps ?? 0) >= 100,
92+
notificationMode: "channel",
8593
},
8694
// Bump streaks
8795
{
@@ -92,6 +100,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
92100
category: "bump",
93101
trigger: { type: "bump", event: "bump_recorded" },
94102
checkCondition: (ctx) => (ctx.bumpStreak ?? 0) >= 3,
103+
notificationMode: "trigger",
95104
},
96105
{
97106
id: "bump_streak_7",
@@ -101,6 +110,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
101110
category: "bump",
102111
trigger: { type: "bump", event: "bump_recorded" },
103112
checkCondition: (ctx) => (ctx.bumpStreak ?? 0) >= 7,
113+
notificationMode: "channel",
104114
},
105115
{
106116
id: "bump_streak_14",
@@ -110,6 +120,7 @@ const BUMP_ACHIEVEMENTS: AchievementDefinition[] = [
110120
category: "bump",
111121
trigger: { type: "bump", event: "bump_recorded" },
112122
checkCondition: (ctx) => (ctx.bumpStreak ?? 0) >= 14,
123+
notificationMode: "channel",
113124
},
114125
];
115126

@@ -126,6 +137,7 @@ const DAILY_ACHIEVEMENTS: AchievementDefinition[] = [
126137
category: "daily",
127138
trigger: { type: "daily", event: "daily_claimed" },
128139
checkCondition: (ctx) => (ctx.dailyStreak ?? 0) >= 1,
140+
notificationMode: "trigger",
129141
},
130142
{
131143
id: "daily_streak_7",
@@ -135,6 +147,7 @@ const DAILY_ACHIEVEMENTS: AchievementDefinition[] = [
135147
category: "daily",
136148
trigger: { type: "daily", event: "daily_claimed" },
137149
checkCondition: (ctx) => (ctx.dailyStreak ?? 0) >= 7,
150+
notificationMode: "trigger",
138151
},
139152
{
140153
id: "daily_streak_30",
@@ -144,6 +157,7 @@ const DAILY_ACHIEVEMENTS: AchievementDefinition[] = [
144157
category: "daily",
145158
trigger: { type: "daily", event: "daily_claimed" },
146159
checkCondition: (ctx) => (ctx.dailyStreak ?? 0) >= 30,
160+
notificationMode: "channel",
147161
},
148162
{
149163
id: "daily_streak_100",
@@ -153,6 +167,7 @@ const DAILY_ACHIEVEMENTS: AchievementDefinition[] = [
153167
category: "daily",
154168
trigger: { type: "daily", event: "daily_claimed" },
155169
checkCondition: (ctx) => (ctx.dailyStreak ?? 0) >= 100,
170+
notificationMode: "channel",
156171
},
157172
{
158173
id: "daily_streak_365",
@@ -162,6 +177,7 @@ const DAILY_ACHIEVEMENTS: AchievementDefinition[] = [
162177
category: "daily",
163178
trigger: { type: "daily", event: "daily_claimed" },
164179
checkCondition: (ctx) => (ctx.dailyStreak ?? 0) >= 365,
180+
notificationMode: "channel",
165181
},
166182
];
167183

@@ -171,70 +187,72 @@ const DAILY_ACHIEVEMENTS: AchievementDefinition[] = [
171187

172188
const XP_ACHIEVEMENTS: AchievementDefinition[] = [
173189
// Level milestones
174-
{
175-
id: "level_1",
176-
name: "First Steps",
177-
description: "Reach level 1",
178-
emoji: "🌱",
179-
category: "xp",
180-
trigger: { type: "xp", event: "xp_gained" },
181-
checkCondition: (ctx) => (ctx.level ?? 0) >= 1,
182-
},
183-
{
184-
id: "level_10",
185-
name: "Rising Star",
186-
description: "Reach level 10",
187-
emoji: "⭐",
188-
category: "xp",
189-
trigger: { type: "xp", event: "xp_gained" },
190-
checkCondition: (ctx) => (ctx.level ?? 0) >= 10,
191-
},
192-
{
193-
id: "level_25",
194-
name: "Experienced",
195-
description: "Reach level 25",
196-
emoji: "💎",
197-
category: "xp",
198-
trigger: { type: "xp", event: "xp_gained" },
199-
checkCondition: (ctx) => (ctx.level ?? 0) >= 25,
200-
},
201-
{
202-
id: "level_50",
203-
name: "Veteran",
204-
description: "Reach level 50",
205-
emoji: "🔷",
206-
category: "xp",
207-
trigger: { type: "xp", event: "xp_gained" },
208-
checkCondition: (ctx) => (ctx.level ?? 0) >= 50,
209-
},
210-
// XP milestones
211-
{
212-
id: "xp_1000",
213-
name: "First Thousand",
214-
description: "Earn 1,000 XP",
215-
emoji: "📈",
216-
category: "xp",
217-
trigger: { type: "xp", event: "xp_gained" },
218-
checkCondition: (ctx) => (ctx.totalXp ?? 0n) >= 1000n,
219-
},
220-
{
221-
id: "xp_10000",
222-
name: "Ten Thousand Club",
223-
description: "Earn 10,000 XP",
224-
emoji: "🚀",
225-
category: "xp",
226-
trigger: { type: "xp", event: "xp_gained" },
227-
checkCondition: (ctx) => (ctx.totalXp ?? 0n) >= 10000n,
228-
},
229-
{
230-
id: "xp_100000",
231-
name: "XP Millionaire",
232-
description: "Earn 1,000,000 XP",
233-
emoji: "💰",
234-
category: "xp",
235-
trigger: { type: "xp", event: "xp_gained" },
236-
checkCondition: (ctx) => (ctx.totalXp ?? 0n) >= 1_000_000n,
237-
},
190+
// {
191+
// id: "level_1",
192+
// name: "First Steps",
193+
// description: "Reach level 1",
194+
// emoji: "🌱",
195+
// category: "xp",
196+
// trigger: { type: "xp", event: "xp_gained" },
197+
// checkCondition: (ctx) => (ctx.level ?? 0) >= 1,
198+
// notificationMode: "silent",
199+
// },
200+
// {
201+
// id: "level_10",
202+
// name: "Rising Star",
203+
// description: "Reach level 10",
204+
// emoji: "⭐",
205+
// category: "xp",
206+
// trigger: { type: "xp", event: "xp_gained" },
207+
// checkCondition: (ctx) => (ctx.level ?? 0) >= 10,
208+
//
209+
// },
210+
// {
211+
// id: "level_25",
212+
// name: "Experienced",
213+
// description: "Reach level 25",
214+
// emoji: "💎",
215+
// category: "xp",
216+
// trigger: { type: "xp", event: "xp_gained" },
217+
// checkCondition: (ctx) => (ctx.level ?? 0) >= 25,
218+
// },
219+
// {
220+
// id: "level_50",
221+
// name: "Veteran",
222+
// description: "Reach level 50",
223+
// emoji: "🔷",
224+
// category: "xp",
225+
// trigger: { type: "xp", event: "xp_gained" },
226+
// checkCondition: (ctx) => (ctx.level ?? 0) >= 50,
227+
// },
228+
// // XP milestones
229+
// {
230+
// id: "xp_1000",
231+
// name: "First Thousand",
232+
// description: "Earn 1,000 XP",
233+
// emoji: "📈",
234+
// category: "xp",
235+
// trigger: { type: "xp", event: "xp_gained" },
236+
// checkCondition: (ctx) => (ctx.totalXp ?? 0n) >= 1000n,
237+
// },
238+
// {
239+
// id: "xp_10000",
240+
// name: "Ten Thousand Club",
241+
// description: "Earn 10,000 XP",
242+
// emoji: "🚀",
243+
// category: "xp",
244+
// trigger: { type: "xp", event: "xp_gained" },
245+
// checkCondition: (ctx) => (ctx.totalXp ?? 0n) >= 10000n,
246+
// },
247+
// {
248+
// id: "xp_100000",
249+
// name: "XP Millionaire",
250+
// description: "Earn 1,000,000 XP",
251+
// emoji: "💰",
252+
// category: "xp",
253+
// trigger: { type: "xp", event: "xp_gained" },
254+
// checkCondition: (ctx) => (ctx.totalXp ?? 0n) >= 1_000_000n,
255+
// },
238256
];
239257

240258
// ─────────────────────────────────────────────────

src/modules/achievements/achievementNotifier.ts

Lines changed: 0 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -104,10 +104,8 @@ async function sendByMode(
104104
await sendToChannel(client, embed, achievementConfig.notificationChannel);
105105
break;
106106
case "trigger":
107-
default:
108107
await sendToTriggerLocation(
109108
client,
110-
member,
111109
embed,
112110
triggerChannel,
113111
achievementConfig,
@@ -165,7 +163,6 @@ async function sendToChannel(
165163
*/
166164
async function sendToTriggerLocation(
167165
client: Client,
168-
member: GuildMember,
169166
embed: ReturnType<typeof createStandardEmbed>,
170167
triggerChannel: TextBasedChannel | undefined,
171168
achievementConfig: AchievementConfig,

0 commit comments

Comments
 (0)