Passage méthode en membre protégé 3

This commit is contained in:
Mylloon 2020-11-24 14:17:44 +01:00
parent c99ce2eb46
commit 704b6eea36

View file

@ -75,7 +75,7 @@ class Commands(commands.Cog):
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
await ctx.send(content = None, embed = embed) await ctx.send(content = None, embed = embed)
@_calc.error @_calc.error
async def calc_error(self, ctx, error): async def _calc_error(self, ctx, error):
await ctx.send("Tu n'as pas spécifié de calcul.") await ctx.send("Tu n'as pas spécifié de calcul.")
@commands.command(name='syntax', aliases = ['syntaxe']) @commands.command(name='syntax', aliases = ['syntaxe'])
@ -172,18 +172,18 @@ class Commands(commands.Cog):
value = str(user[0].created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() value = str(user[0].created_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split()
embed.add_field(name = "Compte créé le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Compte créé le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}")
embed.add_field(name = "Âge du compte", value = self.age_layout(self.get_age(user[0].created_at))) embed.add_field(name = "Âge du compte", value = self._age_layout(self._get_age(user[0].created_at)))
embed.add_field(name = "Mention", value = user[0].mention) embed.add_field(name = "Mention", value = user[0].mention)
value = str(user[0].joined_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split() value = str(user[0].joined_at.astimezone(timezone('Europe/Paris')))[:-13].replace('-', '/').split()
embed.add_field(name = "Serveur rejoint le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}") embed.add_field(name = "Serveur rejoint le", value = f"{value[0][8:]}/{value[0][5:-3]}/{value[0][:4]} à {value[1]}")
embed.add_field(name = "Est sur le serveur depuis", value = self.age_layout(self.get_age(user[0].joined_at))) embed.add_field(name = "Est sur le serveur depuis", value = self._age_layout(self._get_age(user[0].joined_at)))
await ctx.message.add_reaction(emoji = '') await ctx.message.add_reaction(emoji = '')
return await ctx.send(embed = embed) return await ctx.send(embed = embed)
await ctx.send("Tu mentionnes trop d'utilisateurs : `.whois [@Membre]`") await ctx.send("Tu mentionnes trop d'utilisateurs : `.whois [@Membre]`")
def get_age(self, date): def _get_age(self, date):
joursRestants = datetime.now() - date joursRestants = datetime.now() - date
years = joursRestants.total_seconds() / (365.242 * 24 * 3600) years = joursRestants.total_seconds() / (365.242 * 24 * 3600)
months = (years - int(years)) * 12 months = (years - int(years)) * 12
@ -192,7 +192,7 @@ class Commands(commands.Cog):
minutes = (hours - int(hours)) * 60 minutes = (hours - int(hours)) * 60
seconds = (minutes - int(minutes)) * 60 seconds = (minutes - int(minutes)) * 60
return (int(years), int(months), int(days), int(hours), int(minutes), int(seconds)) return (int(years), int(months), int(days), int(hours), int(minutes), int(seconds))
def age_layout(self, tuple): def _age_layout(self, tuple):
time = {} time = {}
time[0], time[1], time[2], time[3], time[4], time[5] = "an", "mois", "jour", "heure", "minute", "seconde" time[0], time[1], time[2], time[3], time[4], time[5] = "an", "mois", "jour", "heure", "minute", "seconde"
for i in range(len(tuple)): for i in range(len(tuple)):
@ -248,7 +248,7 @@ class Commands(commands.Cog):
message = await ctx.send("Aucun salon vocal dans ce serveur, réagissez à ce message avec ✋ pour signaler votre présence (attention, je réagis aussi).") message = await ctx.send("Aucun salon vocal dans ce serveur, réagissez à ce message avec ✋ pour signaler votre présence (attention, je réagis aussi).")
await message.add_reaction(emoji = "") await message.add_reaction(emoji = "")
@_appel.error @_appel.error
async def appel_error(self, ctx, error): async def _appel_error(self, ctx, error):
if isinstance(error, commands.CheckFailure): if isinstance(error, commands.CheckFailure):
await ctx.send("Tu n'as pas la permission de faire cette commande, demande à un professeur.") await ctx.send("Tu n'as pas la permission de faire cette commande, demande à un professeur.")
else: else:
@ -261,7 +261,7 @@ class Commands(commands.Cog):
if len(args) > 2: if len(args) > 2:
question = args[0].replace("<@!", "").replace(">", "").replace("<@", "") question = args[0].replace("<@!", "").replace(">", "").replace("<@", "")
for i in re.findall(r'\d+', question): for i in re.findall(r'\d+', question):
ii = self.user_or_nick(ctx.author.guild.get_member(int(i))) ii = self._user_or_nick(ctx.author.guild.get_member(int(i)))
try: try:
question = question.replace(i, ii) question = question.replace(i, ii)
except: except:
@ -289,7 +289,7 @@ class Commands(commands.Cog):
shuffle(emojis_chosen) shuffle(emojis_chosen)
for i in range(len(args[1:])): for i in range(len(args[1:])):
message += f"{emojis_chosen[i]} -> {propositions[i]}\n" message += f"{emojis_chosen[i]} -> {propositions[i]}\n"
embed = discord.Embed(title = question, description = message,color = randint(0, 0xFFFFFF)).set_footer(text = self.user_or_nick(ctx.author), icon_url = ctx.author.avatar_url) embed = discord.Embed(title = question, description = message,color = randint(0, 0xFFFFFF)).set_footer(text = self._user_or_nick(ctx.author), icon_url = ctx.author.avatar_url)
sondage = await ctx.send(embed = embed) sondage = await ctx.send(embed = embed)
for i in range(len(args[1:])): for i in range(len(args[1:])):
await sondage.add_reaction(emoji = emojis_chosen[i]) await sondage.add_reaction(emoji = emojis_chosen[i])
@ -298,7 +298,7 @@ class Commands(commands.Cog):
return await ctx.send(f"Désolé, mais tu as mis trop de possibilités (maximum : 20)") return await ctx.send(f"Désolé, mais tu as mis trop de possibilités (maximum : 20)")
else: else:
return await ctx.send(f'Désolé, mais il manque des arguments : `.sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>"`') return await ctx.send(f'Désolé, mais il manque des arguments : `.sondage "<Question>" "<Proposition1>" "<Proposition...>" "<Proposition20>"`')
def user_or_nick(self, user): def _user_or_nick(self, user):
if user.nick: if user.nick:
return f"{user.nick} ({user.name}#{user.discriminator})" return f"{user.nick} ({user.name}#{user.discriminator})"
else: else: