Untitled
unknown
plain_text
3 years ago
3.4 kB
8
Indexable
async def edit(interaction: discord.Interaction):
i = 0
with open("noted.json") as n:
noted = json.load(n)
dedans = False
for x in noted:
if x == str(interaction.user.id):
dedans = True
for j in notes:
i += notes[j]
if dedans:
notes[noted[str(interaction.user.id)]] -= 1
if notes[noted[str(interaction.user.id)]] < 0:
notes[noted[str(interaction.user.id)]] = 0
if select.values[0] == "⭐":
notes["⭐"] += 1
noted[str(interaction.user.id)] = "⭐"
elif select.values[0] == "⭐⭐":
notes["⭐⭐"] += 1
noted[str(interaction.user.id)] = "⭐⭐"
elif select.values[0] == "⭐⭐⭐":
notes["⭐⭐⭐"] += 1
noted[str(interaction.user.id)] = "⭐⭐⭐"
elif select.values[0] == "⭐⭐⭐⭐":
notes["⭐⭐⭐⭐"] += 1
noted[str(interaction.user.id)] = "⭐⭐⭐⭐"
elif select.values[0] == "⭐⭐⭐⭐⭐":
notes["⭐⭐⭐⭐⭐"] += 1
noted[str(interaction.user.id)] = "⭐⭐⭐⭐⭐"
moy = (notes["⭐"] + notes["⭐⭐"]*2 + notes["⭐⭐⭐"]*3 + notes["⭐⭐⭐⭐"]*4 + notes["⭐⭐⭐⭐⭐"]*5) / i
embed2 = discord.Embed(
title="Avis sur le serveur !",
description=f"""**Note moyenne** : {moy} \n
⭐ = {notes["⭐"]} \n
⭐⭐ = {notes["⭐⭐"]} \n
⭐⭐⭐ = {notes["⭐⭐⭐"]} \n
⭐⭐⭐⭐ = {notes["⭐⭐⭐⭐"]} \n
⭐⭐⭐⭐⭐ = {notes["⭐⭐⭐⭐⭐"]} \n
\n
\n
**N'hesitez pas à vous aussi laisser votre avis sur le serveur !**
"""
)
await message.edit(embed=embed2, view=view)
await interaction.response.send_message(content="Votre avis a bien été pris en compte merci !", ephemeral=True)
with open('notes.json', 'w') as f:
json.dump(notes, f, indent=4)
with open('noted.json', 'w') as f:
json.dump(noted, f, indent=4)
select.callback = edit
view.add_item(select)
with open("notes.json", "r") as n:
notes2 = json.load(n)
moy = (notes2["⭐"] + notes2["⭐⭐"] + notes2["⭐⭐⭐"] + notes2["⭐⭐⭐⭐"] + notes2["⭐⭐⭐⭐⭐"]) / 5
embed2 = discord.Embed(
title="Avis sur le serveur !",
description=f"""**Note moyenne** : {moy} \n
⭐ = {notes2["⭐"]} \n
⭐⭐ = {notes2["⭐⭐"]} \n
⭐⭐⭐ = {notes2["⭐⭐⭐"]} \n
⭐⭐⭐⭐ = {notes2["⭐⭐⭐⭐"]} \n
⭐⭐⭐⭐⭐ = {notes2["⭐⭐⭐⭐⭐"]} \n
\n
\n
**N'hesitez pas à vous aussi laisser votre avis sur le serveur !**
"""
)
channel = client.get_channel(1063913675481698354)
message = await channel.send(view=view, embed=embed2)Editor is loading...