Message
Message
with open('config.json') as f:
config = json.load(f)
TOKEN = config["token"]
rmk1337 = commands.Bot(command_prefix="+", intents=discord.Intents.all())
DUMP_FOLDER = 'dbip'
CANAL_ID = int(config["allowed_channel_id"])
ROLE_ID = int(config["required_role_id"])
EMBED_COLOR = int(config["embed_color"], 16)
ENCODINGS = ['utf-8', 'latin-1', 'cp1252']
MAX_CONCURRENT_TASKS = 20
BLOCK_SIZE = 1024 * 1024 # 1 Mo
FILE_PROCESSING_TIMEOUT = 5
executor = ThreadPoolExecutor(max_workers=MAX_CONCURRENT_TASKS)
try:
content = await asyncio.wait_for(read_file_in_chunks(file_path, license,
found_event), timeout=FILE_PROCESSING_TIMEOUT)
if content:
associated_info = next((line.strip() for line in content.split('\n') if
license in line), None)
if associated_info:
results.append(associated_info)
found_event.set()
except asyncio.TimeoutError:
print(f"Le traitement du fichier {file_path} a dépassé le temps limite.")
except Exception as e:
print(f"Erreur lors du traitement du fichier {file_path}: {e}")
@rmk1337.tree.command(name="vip", description="Rechercher des informations pour une
licence FiveM")
async def vip(interaction: discord.Interaction, license: str):
if not any(role.id == ROLE_ID for role in interaction.user.roles):
await interaction.response.send_message("Vous n'avez pas le bon rôle pour
utiliser cette commande.", ephemeral=True)
return
if interaction.channel.id != CANAL_ID:
await interaction.response.send_message("Veuillez faire la commande dans le
salon VIP.", ephemeral=True)
return
found_event = asyncio.Event()
results = []
semaphore = asyncio.Semaphore(MAX_CONCURRENT_TASKS)
if results:
results_message = results[0]
embed = discord.Embed(
title="Résultat de la Recherche",
description=results_message,
color=EMBED_COLOR
)
embed.set_footer(text=config["footer_text"])
try:
await interaction.user.send(embed=embed)
await interaction.followup.send("Les résultats ont été envoyés en
message privé.")
except discord.Forbidden:
await interaction.followup.send("Je ne peux pas vous envoyer de message
privé. Veuillez vérifier vos paramètres de confidentialité.")
except discord.HTTPException as e:
print(f"Erreur lors de l'envoi du message: {e}")
await interaction.followup.send("Erreur lors de l'envoi du message
privé. Veuillez réessayer plus tard.")
else:
embed = discord.Embed(
title="Aucune Information Trouvée",
description="Aucune information trouvée pour cette licence.",
color=EMBED_COLOR
)
embed.set_footer(text=config["footer_text"])
await interaction.followup.send(embed=embed)
@rmk1337.event
async def on_ready():
print(f"{rmk1337.user} est connecté et prêt à l'emploi. 🚀")
print("🌟 Bot développé par rmk1337 pour LookData 💻✨")
await rmk1337.change_presence(activity=discord.Game(name=config["bot_status"]))
await rmk1337.tree.sync()
rmk1337.run(TOKEN)