Skip to content

Commit 8c278b3

Browse files
committed
feat(lsms): add 'doctor' subcommand to create training folder for a user
Signed-off-by: Wiibleyde <nathan@bonnell.fr>
1 parent 52701b2 commit 8c278b3

File tree

1 file changed

+124
-1
lines changed

1 file changed

+124
-1
lines changed

bot/commands/handlers/rp/lsms.ts

Lines changed: 124 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
import {
2+
ChannelType,
23
ChatInputCommandInteraction,
34
InteractionContextType,
45
MessageFlags,
@@ -13,7 +14,66 @@ import { hasPermission } from '../../../../utils/permission';
1314
import { lsmsDutyEmbedGenerator, lsmsEmbedGenerator, updateRadioMessage } from '../../../../utils/rp/lsms';
1415
import { prisma } from '../../../../utils/core/database';
1516
import { config } from '@utils/core/config';
16-
import { getSubcommand, getRoleOption, getChannelOption, getStringOption } from '../../../utils/commandOptions';
17+
import { getSubcommand, getRoleOption, getChannelOption, getStringOption, getUserOption } from '../../../utils/commandOptions';
18+
19+
interface Formation {
20+
title: string;
21+
competences: string[];
22+
}
23+
24+
const formations: Formation[] = [
25+
{
26+
title: "Formations secondaires",
27+
competences: [
28+
"PPA",
29+
"Hélicoptère",
30+
"Bateau",
31+
"Psychiatrie",
32+
"Pôle funéraire",
33+
],
34+
},
35+
{
36+
title: "Stagiaire - Explications",
37+
competences: [
38+
"Visite de l'hôpital",
39+
"Visite du bureau psy",
40+
"Visite de la morgue",
41+
"Brancard",
42+
"Mettre / sortir d'un véhicule",
43+
"Intranet",
44+
],
45+
},
46+
{
47+
title: "Stagiaire - Formations",
48+
competences: [
49+
"Conduite de l'ambulance",
50+
"Utilisation de la radio",
51+
"Réanimation",
52+
"Bobologie",
53+
"Radiologie / IRM",
54+
"Anésthésie",
55+
"Opération sous anésthésie générale",
56+
"Opération sous anesthésie locale",
57+
"Suture",
58+
"Don du sang",
59+
"Etat alcolisé / drogué",
60+
"Prise d'otage",
61+
"Visite médicale",
62+
"Gestion d'un patient en état d'arrestation",
63+
"Daronora",
64+
],
65+
},
66+
{
67+
title: "Interne",
68+
competences: [
69+
"Indépendance",
70+
"Fiche patient",
71+
"Rapports médicaux",
72+
"Communication sur la radio LSMS/LSPD",
73+
"Supervision de stagiaires",
74+
],
75+
},
76+
];
1777

1878
export const lsms: ICommand = {
1979
data: new SlashCommandBuilder()
@@ -48,6 +108,21 @@ export const lsms: ICommand = {
48108
)
49109
)
50110
.addSubcommand((subcommand) => subcommand.setName('radio').setDescription('Créer un gestionnaire de radio'))
111+
.addSubcommand((subcommand) =>
112+
subcommand
113+
.setName('doctor')
114+
.setDescription('Créer un dossier de formation pour un médecin')
115+
.addChannelOption((option) =>
116+
option
117+
.setName('forumchannel')
118+
.setDescription('Forum où seront postés les dossiers de formation')
119+
.setRequired(true)
120+
.addChannelTypes(ChannelType.GuildForum)
121+
)
122+
.addUserOption((option) =>
123+
option.setName('user').setDescription('Utilisateur pour lequel créer le dossier').setRequired(true)
124+
)
125+
)
51126
.setContexts([InteractionContextType.Guild, InteractionContextType.PrivateChannel]),
52127
guildIds: ['872119977946263632', config.EVE_HOME_GUILD], // This command is available in all guilds
53128
execute: async (interaction: ChatInputCommandInteraction) => {
@@ -239,6 +314,54 @@ export const lsms: ICommand = {
239314
});
240315
break;
241316
}
317+
case 'doctor': {
318+
const user = getUserOption(interaction, 'user', true);
319+
if (!interaction.guild) {
320+
await interaction.editReply({
321+
embeds: [
322+
lsmsEmbedGenerator().setDescription(
323+
'Cette commande ne peut être utilisée que dans un serveur.'
324+
),
325+
],
326+
});
327+
return;
328+
}
329+
const forumChannel = getChannelOption(interaction, 'forumchannel', true);
330+
if (!forumChannel || forumChannel.type !== ChannelType.GuildForum) {
331+
await interaction.editReply({
332+
embeds: [lsmsEmbedGenerator().setDescription('Le salon doit être un forum.')],
333+
});
334+
return;
335+
}
336+
const guildUserName = interaction.guild.members.cache.get(user.id)?.displayName || user.username;
337+
const thread = await forumChannel.threads.create({
338+
name: `Dossier de formation - ${guildUserName}`,
339+
message: {
340+
embeds: [
341+
lsmsEmbedGenerator()
342+
.setTitle(`Dossier de formation de ${guildUserName}`)
343+
],
344+
},
345+
});
346+
347+
for (const formation of formations) {
348+
await thread.send({
349+
embeds: [
350+
lsmsEmbedGenerator()
351+
.setTitle(formation.title)
352+
],
353+
});
354+
for (const competence of formation.competences) {
355+
await thread.send({
356+
content: `- ${competence}`,
357+
});
358+
}
359+
}
360+
await interaction.editReply({
361+
embeds: [lsmsEmbedGenerator().setDescription('Le dossier de formation a été créé.')],
362+
});
363+
break;
364+
}
242365
default:
243366
await interaction.editReply({
244367
embeds: [lsmsEmbedGenerator().setDescription('Sous-commande inconnue.')],

0 commit comments

Comments
 (0)