Skip to content

Commit 7745af9

Browse files
authored
Merge pull request #138 from Wiibleyde/develop
Develop
2 parents dea2346 + e3dccb0 commit 7745af9

File tree

1 file changed

+125
-1
lines changed

1 file changed

+125
-1
lines changed

bot/commands/handlers/rp/lsms.ts

Lines changed: 125 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,67 @@ 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+
"Anesthésie",
55+
"Opération",
56+
"Suture",
57+
"Don du sang",
58+
"Etat alcoolisé / drogué",
59+
"Prise d'otage",
60+
"Gestion d'un patient en état d'arrestation",
61+
"Autonomie",
62+
"Daronora",
63+
],
64+
},
65+
{
66+
title: "Interne",
67+
competences: [
68+
"Indépendance",
69+
"Fiche patient.es",
70+
"Rapports médicaux",
71+
"Communication sur la radio LSMS/LSPD",
72+
"Supervision de stagiaires",
73+
"Opérations avancées",
74+
"Visite médicale / Certificat médical",
75+
],
76+
},
77+
];
1778

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

0 commit comments

Comments
 (0)