0% found this document useful (0 votes)
48 views

message-1 (1)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
48 views

message-1 (1)

Copyright
© © All Rights Reserved
We take content rights seriously. If you suspect this is your content, claim it here.
Available Formats
Download as TXT, PDF, TXT or read online on Scribd
You are on page 1/ 5

import discord

from discord.ext import commands


from discord import app_commands
import os
import random
import time

# Initialisation du bot
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="!", intents=intents)

# ID du canal de logs (à remplacer par l'ID réel de votre canal de logs)


LOG_CHANNEL_ID = 1298648276509266011 # Remplacez par l'ID du canal de logs

# Dictionnaire pour stocker les emojis pour chaque fichier


EMOJIS = {
"paramount+.txt": 1292074791725039717,
"crunchyroll.txt": 1298291754021425203,
"crunchyroll.txt": 1292077723744997399,
"adn.txt": 1292078344459780148,
"roblox.txt": 1298296298830696478,
"steam.txt": 1292091906792095818,
"cyberghost.txt": 1292145989477728349,
"otacos.txt": 1292187048534347828,
"hotmail.txt": 1298296557572984965,
"starpets.txt": 1292232417817661544,
"blox.land.txt": 1292240284502982666,
"gogoflix.txt": 1292945063827083295,
"nolagvpn.txt": 1292945750593900648,
"fortnite.txt": 1298295792456568883,
}

# Emoji personnalisé pour le bouton "Stock"


STOCK_BUTTON_EMOJI_ID = 1292074417861431388

# Dictionnaire pour gérer les cooldowns des utilisateurs


user_cooldown = {}

# Dictionnaire des rôles et des cooldowns associés (en secondes)


ROLE_COOLDOWNS = {
1294624871619366963: 900, # ID du rôle membre, 15 minutes (900 secondes)
1272641266341118075: 600, # ID du rôle 1 invite, 10 minutes (600 secondes)
1272641388055629854: 300, # ID du rôle 3 invites, 5 minutes (300 secondes)
1296901172069666919: 60, # ID du rôle 4 invites, 1 minute (60 secondes)
}

# Fonction pour vérifier si l'utilisateur est autorisé (ton ID)


def is_owner(interaction):
return interaction.user.id == 1258803869303967915

class CopyButton(discord.ui.Button):
def __init__(self, account_info):
super().__init__(label="Copier", style=discord.ButtonStyle.primary)
self.account_info = account_info

async def callback(self, interaction: discord.Interaction):


# Réponse éphémère avec les informations du compte pour "simuler" une copie
await interaction.response.send_message(content=f"""\n
{self.account_info}
""", ephemeral=True)

class PersistentView(discord.ui.View):
def __init__(self, txt_files):
super().__init__(timeout=None)
self.txt_files = txt_files

# Ajouter les boutons pour chaque fichier


for file_name in self.txt_files:
button_label = file_name.replace('.txt', '')
emoji_id = EMOJIS.get(file_name, None)
emoji = discord.PartialEmoji(name=None, id=emoji_id) if emoji_id else
None

button = discord.ui.Button(
label=f"{button_label}",
style=discord.ButtonStyle.secondary,
emoji=emoji
)
button.callback = self.create_callback(file_name)
self.add_item(button)

# Créer le bouton "Stock"


stock_button = discord.ui.Button(
label="Stock",
style=discord.ButtonStyle.danger,
emoji=discord.PartialEmoji(name=None, id=STOCK_BUTTON_EMOJI_ID)
)
stock_button.callback = self.stock_callback
self.add_item(stock_button)

def get_user_cooldown(self, user):


base_cooldown = 60
for role_id, cooldown in ROLE_COOLDOWNS.items():
if discord.utils.get(user.roles, id=role_id):
return cooldown
return base_cooldown

def create_callback(self, file_name):


async def button_callback(interaction: discord.Interaction):
user_id = interaction.user.id
current_time = time.time()
file_path = os.path.join('./stock', file_name)

with open(file_path, 'r') as f:


lines = [line.strip() for line in f]

if not lines:
error_embed = discord.Embed(
title="Erreur",
description=f"Aucun compte disponible dans {file_name}",
color=discord.Color.red()
)

error_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.gif")
await interaction.response.send_message(embed=error_embed,
ephemeral=True)
return
cooldown = self.get_user_cooldown(interaction.user)
last_click = user_cooldown.get(user_id, 0)

if current_time - last_click < cooldown:


remaining_time = int(cooldown - (current_time - last_click))
cooldown_embed = discord.Embed(
title="Cooldown",
description=f"Vous devez attendre encore {remaining_time}
secondes avant de pouvoir cliquer à nouveau.",
color=discord.Color.red()
)

cooldown_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.g"
)
await interaction.response.send_message(embed=cooldown_embed,
ephemeral=True)
return

user_cooldown[user_id] = current_time
selected_line = random.choice(lines)
lines.remove(selected_line)

with open(file_path, 'w') as f:


for line in lines:
f.write(line + '\n')

file_name_without_ext = file_name.replace('.txt', '')


account_embed = discord.Embed(
title=file_name_without_ext,
color=discord.Color.green()
)

account_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.gif
")
code_block = f"\n{selected_line}"
account_embed.add_field(name="", value=code_block, inline=False)

# Créer la vue pour le bouton de copie


copy_button_view = discord.ui.View()
copy_button = CopyButton(selected_line)
copy_button_view.add_item(copy_button)

await interaction.response.send_message(embed=account_embed,
ephemeral=True, view=copy_button_view)

log_channel = interaction.guild.get_channel(LOG_CHANNEL_ID)
if log_channel:
log_embed = discord.Embed(
title="Compte généré",
description=f"{interaction.user.mention} vient de générer un
compte {file_name_without_ext}",
color=discord.Color.blue()
)

log_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.gif")
await log_channel.send(embed=log_embed)

return button_callback
async def stock_callback(self, interaction: discord.Interaction):
# Compte le nombre de lignes restantes dans chaque fichier
stock_info = ""
folder_path = "./stock"

for file_name in os.listdir(folder_path):


if file_name.endswith('.txt'):
file_path = os.path.join(folder_path, file_name)
with open(file_path, 'r') as f:
line_count = len(f.readlines())

file_name_without_ext = file_name.replace('.txt', '')


status_symbol = "✅" if line_count > 0 else "❌"
stock_info += f"{status_symbol} {file_name_without_ext}:
{line_count} comptes restants\n"

stock_embed = discord.Embed(
description=stock_info or "Aucun fichier .txt trouvé ou tous les
fichiers sont vides.",
color=discord.Color.orange()
)

stock_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.gif")
await interaction.response.send_message(embed=stock_embed, ephemeral=True)

class MyClient(discord.Client):
def __init__(self):
super().__init__(intents=intents)
self.tree = app_commands.CommandTree(self)

async def on_ready(self):


await self.tree.sync()
print(f'Connecté en tant que {self.user}')

client = MyClient()

# Ajout d'une commande "gen" pour générer un panel de boutons avec les
fichiers .txt
@client.tree.command(name="gen", description="Génère un panel de boutons avec les
noms des fichiers .txt")
@app_commands.describe(channel="Le salon où envoyer l'embed")
async def generate_buttons(interaction: discord.Interaction, channel:
discord.TextChannel):
# Vérifier si l'utilisateur a le droit d'exécuter la commande (ton ID)
if not is_owner(interaction):
error_embed = discord.Embed(
title="Erreur de permissions",
description="Seul le propriétaire du bot peut exécuter cette
commande.",
color=discord.Color.red()
)

error_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.g")
await interaction.response.send_message(embed=error_embed, ephemeral=True)
return

folder_path = "./stock"
txt_files = [file_name for file_name in os.listdir(folder_path) if
file_name.endswith('.txt')]
if not txt_files:
error_embed = discord.Embed(
title="Erreur",
description="Aucun fichier .txt trouvé dans le dossier ./stock.",
color=discord.Color.red()
)

error_embed.set_image(url="https://share.creavite.co/6717b782b23406fceac113d8.gif")
await interaction.response.send_message(embed=error_embed, ephemeral=True)
return

view = PersistentView(txt_files)
await channel.send("Voici les fichiers disponibles :", view=view)

client.run("MTI3NjIwNjE5MzIyMzY2MzY0Nw.G_H1vd.OlbaAAsScEV7-Aiqylnt-
rgQ_RA0Y_kSsPRcy8")

You might also like