Améliore la gestion des commandes Discord et l'interface web

This commit is contained in:
skylanix
2025-08-20 23:30:50 +02:00
parent b8ef1e10f8
commit 0628a54fa0
4 changed files with 27 additions and 24 deletions

View File

@@ -72,9 +72,11 @@ bot = DiscordBot(intents=intents)
async def on_message(message: Message):
if message.author == bot.user:
return
commandes = Commande.query.filter_by(discord_enable=True).all()
for commande in commandes:
if message.content.find(commande.trigger) == 0:
if not message.content.startswith('!'):
return
command_name = message.content.split()[0]
commande = Commande.query.filter_by(discord_enable=True, trigger=command_name).first()
if commande:
try:
await message.channel.send(commande.response, suppress_embeds=True)
return

View File

@@ -12,8 +12,8 @@ def commandes():
def add_commande():
trigger = request.form.get('trigger')
response = request.form.get('response')
discord_enable = request.form.get('discord_enable') == 'on'
twitch_enable = request.form.get('twitch_enable') == 'on'
discord_enable = request.form.get('discord_enable') != None
twitch_enable = request.form.get('twitch_enable') != None
if trigger and response:
if not trigger.startswith('!'):

View File

@@ -2,11 +2,12 @@ header nav img {
border-radius: 50%;
}
.table_td {
table th,
table td {
text-align: left;
vertical-align: top;
overflow: hidden;
text-overflow: ellipsis;
white-space: normal;
max-width: 250px;
text-align: left;
vertical-align: top;
}

View File

@@ -6,29 +6,29 @@
<table>
<thead>
<tr>
<th class="table_td">Commande</th>
<th class="table_td">Réponse</th>
<th class="table_td">Discord</th>
<th class="table_td">Twitch</th>
<th class="table_td">Actions</th>
<th>Commande</th>
<th>Réponse</th>
<th>Discord</th>
<th>Twitch</th>
<th>Actions</th>
</tr>
</thead>
<tbody>
{% for commande in commandes %}
<tr>
<td class="table_td">{{ commande.trigger }}</td>
<td class="table_td">{{ commande.response }}</td>
<td class="table_td">
<td>{{ commande.trigger }}</td>
<td>{{ commande.response }}</td>
<td>
<a href="{{ url_for('toggle_discord_commande', commande_id = commande.id) }}" style="text-decoration: none; font-size: 1.2em;">
{{ '✅' if commande.discord_enable else '❌' }}
</a>
</td>
<td class="table_td">
<td>
<a href="{{ url_for('toggle_twitch_commande', commande_id = commande.id) }}" style="text-decoration: none; font-size: 1.2em;">
{{ '✅' if commande.twitch_enable else '❌' }}
</a>
</td>
<td class="table_td">
<td>
<a href="{{ url_for('delete_commande', commande_id = commande.id) }}" onclick="return confirm('Êtes-vous sûr de vouloir supprimer cette commande ?')">Supprimer</a>
</td>
</tr>