Add automatic role assignment on member join for rules acknowledgment

- Introduced a new function `assign_rules_arrival_on_join` to assign the arrival role to members upon joining, based on configuration settings.
- Updated the `on_member_join` event to call the new function, enhancing the user experience by providing immediate role assignment.
- Modified configuration options in the web application to allow enabling or disabling this feature.
- Updated the configurations template to reflect the new role assignment behavior, ensuring clarity for users.
This commit is contained in:
2026-05-04 13:31:11 +02:00
parent 8634f946a1
commit 4e6f8bec3a
4 changed files with 50 additions and 3 deletions
+1
View File
@@ -50,6 +50,7 @@ def updateConfiguration():
'auto_rooms_enable': 'auto_rooms_channel_id',
'twitch_commands_enable': 'twitch_channel',
'rules_ack_enable': 'rules_channel_id',
'rules_arrival_on_join_enable': 'rules_ack_section_in_form',
}
# Ne mettre à jour les rôles staff que si la liste a été rendue dans le formulaire.
+7 -2
View File
@@ -76,7 +76,7 @@
<div class="bg-gray-50 dark:bg-gray-700/50 rounded-lg p-4 space-y-4">
<h3 class="font-medium text-gray-800 dark:text-gray-200">Règlement (embed + bouton)</h3>
<p class="text-sm text-gray-600 dark:text-gray-400">
Publie un message fixe dans un canal avec un embed et un bouton « J'ai lu le règlement ». Au clic, le membre reçoit le rôle d'arrivée. Si un canal « présentation » est configuré, le premier message du membre dans ce canal lui attribue le rôle membre validé et retire le rôle d'arrivée.
Publie un message fixe dans un canal avec un embed et un bouton « J'ai lu le règlement ». Par défaut, le <strong>rôle d'arrivée</strong> n'est donné qu'au <strong>clic sur le bouton</strong> (pas automatiquement en rejoignant le serveur). Tu peux cocher l'option ci-dessous pour l'attribuer aussi dès le join. Si un canal « présentation » est configuré, le premier message du membre (avec le rôle d'arrivée) dans ce canal lui attribue le rôle membre validé et retire le rôle d'arrivée — utilise un canal où les nouveaux peuvent écrire (souvent différent du salon charte en lecture seule).
</p>
<input type="hidden" name="rules_ack_section_in_form" value="1">
<label class="flex items-center gap-2 cursor-pointer">
@@ -84,6 +84,11 @@
class="w-5 h-5 rounded border-gray-300 dark:border-gray-600 text-indigo-600 focus:ring-indigo-500 dark:bg-gray-700">
<span class="text-sm text-gray-700 dark:text-gray-300">Activer le règlement avec bouton</span>
</label>
<label class="flex items-center gap-2 cursor-pointer">
<input type="checkbox" name="rules_arrival_on_join_enable" {% if configuration.getValue('rules_arrival_on_join_enable') %}checked{% endif %}
class="w-5 h-5 rounded border-gray-300 dark:border-gray-600 text-indigo-600 focus:ring-indigo-500 dark:bg-gray-700">
<span class="text-sm text-gray-700 dark:text-gray-300">Donner le rôle d'arrivée dès qu'un membre rejoint le serveur (en plus du bouton)</span>
</label>
<div>
<label for="rules_channel_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Canal du règlement (message + bouton)</label>
<select name="rules_channel_id" id="rules_channel_id"
@@ -116,7 +121,7 @@
</div>
<div class="grid grid-cols-1 md:grid-cols-2 gap-4">
<div>
<label for="rules_arrival_role_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Rôle d'arrivée (au clic sur le bouton)</label>
<label for="rules_arrival_role_id" class="block text-sm font-medium text-gray-700 dark:text-gray-300 mb-2">Rôle d'arrivée (bouton, et à la connexion si l'option ci-dessus est cochée)</label>
<select name="rules_arrival_role_id" id="rules_arrival_role_id"
class="w-full px-4 py-2 rounded-lg border border-gray-300 dark:border-gray-600 bg-white dark:bg-gray-700 text-gray-900 dark:text-white focus:ring-2 focus:ring-indigo-500 focus:border-transparent transition-all">
<option value="">— Aucun —</option>