message-1 (1)
message-1 (1)
# Initialisation du bot
intents = discord.Intents.default()
bot = commands.Bot(command_prefix="!", intents=intents)
class CopyButton(discord.ui.Button):
def __init__(self, account_info):
super().__init__(label="Copier", style=discord.ButtonStyle.primary)
self.account_info = account_info
class PersistentView(discord.ui.View):
def __init__(self, txt_files):
super().__init__(timeout=None)
self.txt_files = txt_files
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)
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)
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)
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)
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"
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)
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")