Initialisation du repository de Beta
This commit is contained in:
commit
14985f6dbb
9469 changed files with 1903273 additions and 0 deletions
35
commandes/security/list_warnings.py
Normal file
35
commandes/security/list_warnings.py
Normal file
|
|
@ -0,0 +1,35 @@
|
|||
import discord
|
||||
import json
|
||||
import os
|
||||
|
||||
WARNINGS_FILE = 'warnings.json'
|
||||
|
||||
def load_warnings():
|
||||
if os.path.exists(WARNINGS_FILE):
|
||||
with open(WARNINGS_FILE, 'r', encoding='utf-8') as f:
|
||||
return json.load(f)
|
||||
return {}
|
||||
|
||||
async def execute(bot, params, message):
|
||||
all_warnings = load_warnings()
|
||||
guild_id = str(message.guild.id)
|
||||
if guild_id not in all_warnings:
|
||||
await message.channel.send("Aucune avertissement enregistré pour ce serveur.")
|
||||
return
|
||||
|
||||
embed = discord.Embed(
|
||||
title="Avertissements du serveur",
|
||||
description="Liste des utilisateurs ayant des avertissements :",
|
||||
color=discord.Color.orange()
|
||||
)
|
||||
|
||||
for user_id, warnings in all_warnings[guild_id].items():
|
||||
member = message.guild.get_member(int(user_id))
|
||||
name = member.display_name if member else f"Utilisateur {user_id}"
|
||||
embed.add_field(
|
||||
name=f"{name} ({len(warnings)} avertissements)",
|
||||
value="Dernier : " + warnings[-1]['reason'][:100] + "..." if len(warnings[-1]['reason']) > 100 else warnings[-1]['reason'],
|
||||
inline=False
|
||||
)
|
||||
|
||||
await message.channel.send(embed=embed)
|
||||
Loading…
Add table
Add a link
Reference in a new issue