-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathFrieren.py
More file actions
151 lines (130 loc) · 5.46 KB
/
Copy pathFrieren.py
File metadata and controls
151 lines (130 loc) · 5.46 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
import discord
from discord import app_commands
from discord.ext import commands
import os
import subprocess
from dotenv import load_dotenv
from function.Maid import Maid
from function.Eru import Eru
from function.Yui import Yui
from function.Rias import Rias
# Chargement des variables d'environnement
load_dotenv()
TOKEN = os.getenv('TOKEN')
DEV_GUILD_ID = int(os.getenv('DEV_GUILD_ID'))
# Configuration du bot
intents = discord.Intents.all()
# intents.message_content = True
bot = commands.Bot(command_prefix="!", intents=intents)
@bot.event
async def on_ready():
subprocess.run('cls', shell=True) # Efface la console (Windows uniquement)
print(f"{bot.user} est Réveillé !\n")
print(f"ID du serveur configuré : {DEV_GUILD_ID}")
try:
synced = await bot.tree.sync()
print(f"Synced {len(synced)} command(s) synchroniser")
except Exception as e:
print(f"Erreur lors de la synchronisation des commandes : {e}")
@bot.event
async def on_message(message):
if message.author == bot.user:
return
try:
member = message.author
message_content = message.content
nom_serv = message.guild.name
print(f'Sur le serveur : {nom_serv} \nMessage de {member.name} : {message_content}')
except Exception as e:
print(f"Erreur lors de la réception du message : {e}")
await bot.process_commands(message)
# Commande : /hello
@bot.tree.command(
name="hello",
description="Petit bonjour de Frieren",
)
async def hello(interaction: discord.Interaction, member: discord.Member):
if member is None:
await interaction.response.send_message("Veuillez mentionner un membre valide.", ephemeral=True)
return
await interaction.response.send_message(f"Hello {member.mention} :kiss:")
# Commande : /hello_world
@bot.tree.command(
name="hello_world",
description="Un petit hello world ma foi aussi simple que ça :)",
)
async def hello_world(interaction: discord.Interaction):
await interaction.response.send_message("Hello World")
# Commande : /code
#commands without selenium
@bot.tree.command(
name="code",
description="Pour obtenir les code d'échange de Genshin ou Honkai star rail",
)
@app_commands.describe(jeux_entrer="Le jeu pour lequel vous souhaitez récupérer les codes")
@app_commands.choices(jeux_entrer=[
app_commands.Choice(name="Genshin", value="genshin"),
app_commands.Choice(name="Honkai Star Rail", value="hsr")
])
# @app_commands.describe(jeux="Le jeu pour lequel vous souhaitez récupérer les codes")
async def code(interaction: discord.Interaction, jeux_entrer: app_commands.Choice[str]):
# met les caractère en minuscule
jeu = jeux_entrer.value.lower()
# envoie une reponse temporaire afin de montrer que le bot traite la commande
# await interaction.response.send_message("Frieren réfléchie", ephemeral=True)
await interaction.response.defer(ephemeral=True)
# appelle la fonction Maid.scrap() pour récupérer les codes
code_scrap = await Maid.scrap(jeu)
# envoie le code d'échange
await interaction.followup.send(f"Code d'échange : \n{code_scrap}")
@bot.tree.command(
name="my_id",
description="Donne l'id de l'utilisateur",
)
async def my_id(interaction: discord.Interaction):
await interaction.response.defer(ephemeral=True)
await interaction.followup.send(f"Votre ID : {interaction.user.id}")
#commands without selenium
@bot.tree.command(
name="valorant_rank",
description="Donne le rank de l'utilisateur sur valorant",
)
@app_commands.describe(pseudo="Le pseudo de l'utilisateur")
@app_commands.describe(tag="Le tag de l'utilisateur")
async def valorant_rank(interaction: discord.Interaction, pseudo: str, tag: str):
await interaction.response.defer(ephemeral=True)
rank = await Maid.valorant_tracker_rank(pseudo, tag)
await interaction.followup.send(f"Le rank de {pseudo}#{tag} est : {rank}")
#commands without selenium
@bot.tree.command(
name="waifu",
description="Donne une waifu aléatoire",
)
async def waifu(interaction: discord.Interaction):
await interaction.response.defer()
name, alternate_name, age, birthday, height, weight, blood_type, waifu_classification, description, like_rank, popularity_rank, image_url = await Eru.random_waifu()
embed = discord.Embed(title=name, description=description, color=discord.Color.blue())
embed.set_thumbnail(url=image_url)
embed.add_field(name="Alternate Name", value=alternate_name, inline=True)
embed.add_field(name="Age", value=age, inline=True)
embed.add_field(name="Birthday", value=birthday, inline=True)
embed.add_field(name="Height", value=height, inline=True)
embed.add_field(name="Weight", value=weight, inline=True)
embed.add_field(name="Blood Type", value=blood_type, inline=True)
embed.add_field(name="Waifu Classification", value=waifu_classification, inline=True)
embed.add_field(name="Like Rank", value=like_rank, inline=True)
embed.add_field(name="Popularity Rank", value=popularity_rank, inline=True)
await interaction.followup.send(embed=embed)
#commands without selenium
@bot.tree.command(
name="rule34",
description="Donne une image rule34 avec les tags choisit",
)
@app_commands.describe(tags="Les tags pour la recherche")
async def rule34(interaction: discord.Interaction, tags: str):
await interaction.response.defer()
image_url = await Rias.rule34(tags)
await interaction.followup.send(image_url)
# Démarrage du bot et le serveur web
Yui.alive()
bot.run(TOKEN)