change gitlab changelogs + new loading of env variables part. 2
This commit is contained in:
parent
155ff9244e
commit
92fe7a0e92
1 changed files with 17 additions and 17 deletions
|
@ -1,12 +1,10 @@
|
|||
import discord
|
||||
from os import environ, path
|
||||
from re import findall
|
||||
from discord.ext import commands, tasks
|
||||
from random import randint, shuffle
|
||||
from discord_slash import cog_ext
|
||||
from utils.reminder import Reminder
|
||||
from utils.core import map_list_among_us, getURLsInString, getMentionInString, cleanCodeStringWithMentionAndURLs, cleanUser, userOrNick
|
||||
from utils.core import mySendHidden, mentionToUser, getChangelogs, isSlash
|
||||
from utils.core import mySendHidden, mentionToUser, getChangelogs, getActualVersion, isSlash, load
|
||||
from utils.time import stringTempsVersSecondes, nowUTC, intToDatetime, timedeltaToString, timestampScreen, getAge, ageLayout, nowCustom
|
||||
|
||||
def setup(client):
|
||||
|
@ -16,7 +14,7 @@ class Utils(commands.Cog):
|
|||
"""Commandes essentielles."""
|
||||
def __init__(self, client):
|
||||
self.client = client
|
||||
self.customTimezone = environ['TIMEZONE']
|
||||
self.customTimezone = load(["TIMEZONE"])["TIMEZONE"]
|
||||
self._reminderLoop.start()
|
||||
|
||||
@commands.command(name='ping')
|
||||
|
@ -235,8 +233,7 @@ class Utils(commands.Cog):
|
|||
voice = len(voice_channels)
|
||||
nombreServeur = len(self.client.guilds)
|
||||
|
||||
with open(path.join(path.dirname(path.dirname(path.dirname(__file__))), "README.md"), "r") as file:
|
||||
version = findall(r'https://img.shields.io/badge/version-(\d+\.\d+)', file.readlines()[2])[0]
|
||||
version = getActualVersion()
|
||||
|
||||
embed.add_field(name = "Dev", value = f"[{appinfo.owner}](https://gitlab.com/Mylloon)")
|
||||
embed.add_field(name = f"Serveur{'s' if nombreServeur > 1 else ''}", value = f"`{nombreServeur}`")
|
||||
|
@ -247,8 +244,8 @@ class Utils(commands.Cog):
|
|||
embed.add_field(name = "Timezone", value = f"`{self.customTimezone}`")
|
||||
embed.add_field(name = "Version", value = f"`{version}`")
|
||||
changes = getChangelogs(version)
|
||||
if changes != None and changes != 0:
|
||||
embed.add_field(name = "Changements", value = f"[Lien Gitlab]({changes[0]})")
|
||||
if changes[0] == 200:
|
||||
embed.add_field(name = "Changements", value = f"[Lien Gitlab]({changes[1]})")
|
||||
embed.set_footer(text = f"Basé sur discord.py {discord.__version__}")
|
||||
try:
|
||||
if fromSlash != True:
|
||||
|
@ -630,22 +627,25 @@ class Utils(commands.Cog):
|
|||
"""Affiche les changements de la dernière version ou d'une version précise.\n ➡ Syntaxe: {PREFIX}changelogs/changelog/changement/changements [version]"""
|
||||
version, fromSlash, _ = isSlash(version)
|
||||
if not version:
|
||||
version = 'latest'
|
||||
version = 'actual'
|
||||
changes = getChangelogs(version.replace(',', '.'))
|
||||
if changes == None or changes == 0:
|
||||
if changes[0] != 200:
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '❌')
|
||||
if changes == None:
|
||||
message = "Veuillez renseigner un numéro de version valide et existant."
|
||||
if changes[0] == 404:
|
||||
message = "Veuillez renseigner un numéro de version valide et existant. Peut-être que vous utilisez une version de développement."
|
||||
elif changes[0] == 429:
|
||||
message = "Trop de requêtes sur l'API de Gitlab, réessayez plus tard."
|
||||
else:
|
||||
message = "Trop de requêtes sur l'API de Github, réessayez plus tard."
|
||||
message = f"Erreur API inconnue ({changes[0]})."
|
||||
return await mySendHidden(ctx, fromSlash, message)
|
||||
if fromSlash != True:
|
||||
await ctx.message.add_reaction(emoji = '✅')
|
||||
if len(changes[2]) > 2048:
|
||||
changes[2] = f"{changes[2][:1900]}..."
|
||||
embed = discord.Embed(description = f"[lien vers la page Github]({changes[0]})\n\n{changes[2]}", color = discord.Colour.random())
|
||||
embed.set_author(name = f"Changements de la v{changes[1]}")
|
||||
changements = changes[3].replace("## ", "◦ ").replace("# ", "• ")
|
||||
if len(changements) > 2048:
|
||||
changements = f"{changements[:1900]}..."
|
||||
embed = discord.Embed(description = f"[lien vers la page Gitlab]({changes[1]})\n\n{changements}", color = discord.Colour.random())
|
||||
embed.set_author(name = f"Changements de la v{changes[2]}")
|
||||
await ctx.send(embed = embed)
|
||||
@cog_ext.cog_slash(name="changelogs", description = "Affiche les changements de la dernière version ou d'une version précise.")
|
||||
async def __changelogs(self, ctx, version = None):
|
||||
|
|
Reference in a new issue