Skip to content

Commit c27095b

Browse files
committed
Add medicine & eponym posts, quiz & schedulers
Add interactive / scheduled content: new slash commands (medicine, eponym, quizz), scheduler features (features/medicinePosts.ts, features/eponymPosts.ts) and initialization in index.ts. Introduce utilities to generate and deduplicate AI-generated content with persistent history (utils/medicineUtils.ts, utils/eponymUtils.ts) and a typed ExtendedClient (types/ExtendedClient.ts). Register new commands and handlers in events/ready.ts and events/interactionCreate.ts. Update config.example.ts to add MEDICINE/EPONYM post settings, revise model identifiers and system prompt. Bump dependencies (node-cron, openai, discord.js), adjust tsconfig module resolution, and add data/ to .gitignore.
1 parent 4edb7d1 commit c27095b

15 files changed

Lines changed: 1066 additions & 37 deletions

.gitignore

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -111,3 +111,6 @@ config.ts
111111
channels.ts
112112
package-lock.json
113113
bun.lock
114+
115+
# Medicine posts data
116+
data/

commands/eponym.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// commands/eponym.ts
2+
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js';
3+
import type { ExtendedClient } from '../types/ExtendedClient.js';
4+
import { EPONYM_POSTS_CONFIG } from '../config.js';
5+
import { generateEponymPost, saveEponymToHistory } from '../utils/eponymUtils.js';
6+
7+
export const data = new SlashCommandBuilder()
8+
.setName('eponym')
9+
.setDescription('Manually trigger an eponym post (for testing)');
10+
11+
export async function execute(interaction: CommandInteraction, client: ExtendedClient) {
12+
try {
13+
await interaction.deferReply({ ephemeral: true });
14+
15+
console.log('Manually generating eponym post...');
16+
17+
const result = await generateEponymPost(client);
18+
if (!result) {
19+
await interaction.editReply('❌ Failed to generate eponym post (could not find unique eponym after multiple attempts)');
20+
return;
21+
}
22+
23+
const { name, content } = result;
24+
25+
// Get the configured channel
26+
const channel = await client.channels.fetch(EPONYM_POSTS_CONFIG.channelId);
27+
if (!channel || !(channel instanceof TextChannel)) {
28+
await interaction.editReply('❌ Invalid channel configured for eponym posts');
29+
return;
30+
}
31+
32+
// Send the post
33+
await channel.send(content);
34+
35+
// Save to history (with built-in duplicate protection)
36+
saveEponymToHistory(name);
37+
38+
await interaction.editReply(`✅ Eponym post sent: ${name}`);
39+
console.log(`✅ Manual eponym post sent: ${name}`);
40+
} catch (error) {
41+
console.error('Error in eponym command:', error);
42+
await interaction.editReply('❌ An error occurred while generating the eponym post');
43+
}
44+
}

commands/medicine.ts

Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
// commands/medicine.ts
2+
import { CommandInteraction, SlashCommandBuilder, TextChannel } from 'discord.js';
3+
import type { ExtendedClient } from '../types/ExtendedClient.js';
4+
import { MEDICINE_POSTS_CONFIG } from '../config.js';
5+
import { generateMedicinePost, saveToHistory } from '../utils/medicineUtils.js';
6+
7+
export const data = new SlashCommandBuilder()
8+
.setName('medicine')
9+
.setDescription('Manually trigger a medicine post (for testing)');
10+
11+
export async function execute(interaction: CommandInteraction, client: ExtendedClient) {
12+
try {
13+
await interaction.deferReply({ ephemeral: true });
14+
15+
console.log('Manually generating medicine post...');
16+
17+
const result = await generateMedicinePost(client);
18+
if (!result) {
19+
await interaction.editReply('❌ Failed to generate medicine post (could not find unique medicine after multiple attempts)');
20+
return;
21+
}
22+
23+
const { name, content } = result;
24+
25+
// Get the configured channel
26+
const channel = await client.channels.fetch(MEDICINE_POSTS_CONFIG.channelId);
27+
if (!channel || !(channel instanceof TextChannel)) {
28+
await interaction.editReply('❌ Invalid channel configured for medicine posts');
29+
return;
30+
}
31+
32+
// Send the post
33+
await channel.send(content);
34+
35+
// Save to history (with built-in duplicate protection)
36+
saveToHistory(name);
37+
38+
await interaction.editReply(`✅ Medicine post sent: ${name}`);
39+
console.log(`✅ Manual medicine post sent: ${name}`);
40+
} catch (error) {
41+
console.error('Error in medicine command:', error);
42+
await interaction.editReply('❌ An error occurred while generating the medicine post');
43+
}
44+
}

0 commit comments

Comments
 (0)