adding attachments to citation
This commit is contained in:
parent
c2f4444792
commit
36679d08b4
1 changed files with 32 additions and 4 deletions
34
src/main.py
34
src/main.py
|
@ -114,17 +114,45 @@ async def on_message(message):
|
||||||
if int(link[32:-38]) == message.guild.id:
|
if int(link[32:-38]) == message.guild.id:
|
||||||
msgID = await client.get_channel(int(link[51:-19])).fetch_message(int(link[70:]))
|
msgID = await client.get_channel(int(link[51:-19])).fetch_message(int(link[70:]))
|
||||||
couleur = 0x2f3136
|
couleur = 0x2f3136
|
||||||
|
msgFiles = msgID.attachments
|
||||||
|
imageExtensions = ["jpg", "jpeg", "png", "webp", "gif"]
|
||||||
|
if len(msgFiles) > 1:
|
||||||
|
listOfFiles = ""
|
||||||
|
for i in range(0, len(msgFiles)):
|
||||||
|
listOfFiles = f"{listOfFiles}, {msgFiles[i].filename}"
|
||||||
|
listOfFiles = listOfFiles[2:]
|
||||||
if len(msgID.content) > 0:
|
if len(msgID.content) > 0:
|
||||||
embed = discord.Embed(description = msgID.content, colour = couleur)
|
desc = f"{msgID.content}\n\nIl y a plusieurs fichiers dans ce message : {listOfFiles}"
|
||||||
else:
|
else:
|
||||||
embed = discord.Embed(description = "Pas de message (image ? vidéo ? intégration ?)", colour = couleur) # peut etre implémenter autre chose
|
desc = f"Il y a plusieurs fichiers dans ce message : {listOfFiles}"
|
||||||
|
else:
|
||||||
|
if len(msgFiles) == 1:
|
||||||
|
if msgFiles[0].filename[-4:].split('.')[1] in imageExtensions:
|
||||||
|
if len(msgID.content) > 0:
|
||||||
|
desc = msgID.content
|
||||||
|
else:
|
||||||
|
desc = f"Une image jointe : {msgFiles[0].filename}"
|
||||||
|
else:
|
||||||
|
linkFile = msgFiles[0].url
|
||||||
|
if len(msgID.content) > 0:
|
||||||
|
desc = msgID.content
|
||||||
|
else:
|
||||||
|
desc = f"Un fichier joint : {msgFiles[0].filename}"
|
||||||
|
embed = discord.Embed(description = desc, colour = couleur)
|
||||||
auteur = "Auteur"
|
auteur = "Auteur"
|
||||||
if message.author == msgID.author:
|
if message.author == msgID.author:
|
||||||
auteur = "Auteur & Citateur"
|
auteur = "Auteur & Citateur"
|
||||||
embed.add_field(name = auteur, value = msgID.author.mention, inline=True)
|
embed.add_field(name = auteur, value = msgID.author.mention, inline=True)
|
||||||
|
try:
|
||||||
|
if len(msgFiles) == 1:
|
||||||
|
if msgFiles[0].filename[-4:].split('.')[1] in imageExtensions:
|
||||||
|
embed.set_image(url=msgFiles[0].url)
|
||||||
|
else:
|
||||||
|
embed.add_field(name = "Fichier", value = f"[Lien]({linkFile})", inline=True)
|
||||||
|
except:
|
||||||
|
pass
|
||||||
embed.add_field(name = "Message", value = f"{msgID.channel.mention} - [Lien Message]({linkURL})", inline=True)
|
embed.add_field(name = "Message", value = f"{msgID.channel.mention} - [Lien Message]({linkURL})", inline=True)
|
||||||
embed.set_author(name = "Citation", icon_url = msgID.author.avatar_url)
|
embed.set_author(name = "Citation", icon_url = msgID.author.avatar_url)
|
||||||
|
|
||||||
icon_url = message.author.avatar_url
|
icon_url = message.author.avatar_url
|
||||||
|
|
||||||
date_1 = str(msgID.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split()
|
date_1 = str(msgID.created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split()
|
||||||
|
|
Reference in a new issue