From 384cb52fdcda37db93e046a0797413bb0f6ffe5e Mon Sep 17 00:00:00 2001 From: Mylloon Date: Mon, 22 Feb 2021 02:39:01 +0100 Subject: [PATCH] Changing random color according with Rapptz/discord.py#6067 --- src/cogs/help.py | 4 ++-- src/cogs/internet.py | 12 ++++++------ src/cogs/music.py | 6 +++--- src/cogs/utils.py | 24 ++++++++++++------------ 4 files changed, 23 insertions(+), 23 deletions(-) diff --git a/src/cogs/help.py b/src/cogs/help.py index 316717b..9f86323 100644 --- a/src/cogs/help.py +++ b/src/cogs/help.py @@ -19,7 +19,7 @@ class Help(commands.Cog): """Liste des Cog""" halp=discord.Embed(title = 'Liste des catégories et commandes sans catégorie', description = f'Utilisez `{ctx.prefix}help [catégorie]` pour en savoir plus sur elles et leur commande.', - color = randint(0, 0xFFFFFF)) + color = discord.Colour.random()) for name_cog in self.client.cogs: liste_cmds = "" nb_cmds = 0 @@ -50,7 +50,7 @@ class Help(commands.Cog): for x in self.client.cogs: for y in cog: if x == y: - halp = discord.Embed(title = f'{cog[0]} - Liste des commandes', description = self.client.cogs[cog[0]].__doc__, color = randint(0, 0xFFFFFF)) + halp = discord.Embed(title = f'{cog[0]} - Liste des commandes', description = self.client.cogs[cog[0]].__doc__, color = discord.Colour.random()) for c in self.client.get_cog(y).get_commands(): if not c.hidden: cmds_help = str(c.help).split("\n") diff --git a/src/cogs/internet.py b/src/cogs/internet.py index 434283a..f113b9e 100644 --- a/src/cogs/internet.py +++ b/src/cogs/internet.py @@ -53,7 +53,7 @@ class Internet(commands.Cog): image = ["png", "jpg", "jpeg", "bmp", "gif"] if submission.url[-3:] in image: - embed = discord.Embed(title = f"r/{subredditchoix} pour {ctx.author.name}", color = randint(0, 0xFFFFFF), description = f"[lien du meme]({submission.url})") + embed = discord.Embed(title = f"r/{subredditchoix} pour {ctx.author.name}", color = discord.Colour.random(), description = f"[lien du meme]({submission.url})") embed.set_footer(text = f"Meme de Reddit") embed.set_image(url = submission.url) message = await ctx.send(embed = embed) @@ -95,7 +95,7 @@ class Internet(commands.Cog): name = f"{ctx.author.nick} ({ctx.author.name}#{ctx.author.discriminator})" else: name = f"{ctx.author.name}" - embed = discord.Embed(title = f"Poticha pour {name}", colour = randint(0, 0xFFFFFF)) + embed = discord.Embed(title = f"Poticha pour {name}", colour = discord.Colour.random()) cat = self._random_image("http://aws.random.cat/meow") embed.set_image(url = cat[0]['file']) embed.set_footer(text = f"random.cat a pris {cat[1]} ms.") @@ -111,7 +111,7 @@ class Internet(commands.Cog): name = f"{ctx.author.nick} ({ctx.author.name}#{ctx.author.discriminator})" else: name = f"{ctx.author.name}" - embed = discord.Embed(title = f"Potichien pour {name}", colour = randint(0, 0xFFFFFF)) + embed = discord.Embed(title = f"Potichien pour {name}", colour = discord.Colour.random()) dog = self._random_image("https://dog.ceo/api/breeds/image/random") embed.set_image(url = dog[0]['message']) embed.set_footer(text = f"dog.ceo a pris {dog[1]} ms.") @@ -128,7 +128,7 @@ class Internet(commands.Cog): else: choice_of_nsfw = choice(liste_hot) if ctx.channel.is_nsfw(): - embed = discord.Embed(title = f"{choice_of_nsfw.capitalize()} pour {ctx.author.name}", colour = randint(0, 0xFFFFFF)) + embed = discord.Embed(title = f"{choice_of_nsfw.capitalize()} pour {ctx.author.name}", colour = discord.Colour.random()) nsfw = self._random_image(f'http://api.o{choice_of_nsfw}.ru/noise/') embed.set_image(url = f"http://media.o{choice_of_nsfw}.ru/{nsfw[0][0]['preview']}") embed.set_footer(text = f"o{choice_of_nsfw}.ru a pris {nsfw[1]} ms.") @@ -168,14 +168,14 @@ class Internet(commands.Cog): choix_site = arg.lower() if arg.lower() == "liste": - embed = discord.Embed(title = "Liste des sources", color = randint(0, 0xFFFFFF), description = ", ".join([key.capitalize() for key in rss_website.keys()])) + embed = discord.Embed(title = "Liste des sources", color = discord.Colour.random(), description = ", ".join([key.capitalize() for key in rss_website.keys()])) return await ctx.send(embed = embed) newsfeed = feedparser.parse(rss_website[choix_site]) info = choice([newsfeed.entries[i] for i in range(0, 10 if len(newsfeed.entries) > 10 else len(newsfeed.entries))]) desc = "Pas de description trouvée." if "

" in info.description or "" in info.description else info.description - embed = discord.Embed(title = info.title, color = randint(0, 0xFFFFFF), description = f"[**lien de la news**]({info.link})\n\n{desc}") + embed = discord.Embed(title = info.title, color = discord.Colour.random(), description = f"[**lien de la news**]({info.link})\n\n{desc}") try: embed.set_author(name = info.author) except: diff --git a/src/cogs/music.py b/src/cogs/music.py index 45ad0d6..a7d540d 100644 --- a/src/cogs/music.py +++ b/src/cogs/music.py @@ -157,7 +157,7 @@ class Song: def create_embed(self): embed = (discord.Embed(title="Joue", description=f"\n[{self.source.title}]({self.source.url})\n", - color=randint(0, 0xFFFFFF)) + color=discord.Colour.random()) .add_field(name="Durée", value=self.source.duration) .add_field(name="Demandé par", value=self.requester.mention) .add_field(name="Chaîne", value=f"[{self.source.uploader}]({self.source.uploader_url})") @@ -419,7 +419,7 @@ class Music(commands.Cog): for i, song in enumerate(ctx.voice_state.songs[start:end], start=start): queue += f"`{i + 1}.` [**{song.source.title}**]({song.source.url})\n" - embed = (discord.Embed(description=f"**{len(ctx.voice_state.songs)} piste{'s' if len(ctx.voice_state.songs)>1 else ''} :**\n\n{queue}", color = randint(0, 0xFFFFFF)) + embed = (discord.Embed(description=f"**{len(ctx.voice_state.songs)} piste{'s' if len(ctx.voice_state.songs)>1 else ''} :**\n\n{queue}", color = discord.Colour.random()) .set_footer(text=f"Page {page}/{pages}")) await ctx.send(embed=embed) @@ -500,7 +500,7 @@ class Music(commands.Cog): message = await ctx.send(f":mag: **Cherche les paroles de ** `{song}`") temps_requete = int(round(time.time() * 1000)) song_genius = genius.search_song(song) - couleur_embed = randint(0, 0xFFFFFF) + couleur_embed = discord.Colour.random() try: paroles = song_genius.lyrics except: diff --git a/src/cogs/utils.py b/src/cogs/utils.py index b4f6a4d..2c439e2 100644 --- a/src/cogs/utils.py +++ b/src/cogs/utils.py @@ -20,14 +20,14 @@ class Utils(commands.Cog): async def _ping(self, ctx, *, question = '0'): """Affiche mon ping.⁢⁢⁢⁢⁢\n ➡ Syntaxe: .ping [help]⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" if question == 'help': - return await ctx.send(embed = discord.Embed(color = randint(0, 0xFFFFFF), description = ":hourglass: correspond au temps entre deux battements de cœurs (en millisecondes)\n\n:stopwatch: correspond au temps que met le client a calculer le ping (en millisecondes)\n\n:heartbeat: correspond au temps que met le client a réagir au messages (en millisecondes)")) + return await ctx.send(embed = discord.Embed(color = discord.Colour.random(), description = ":hourglass: correspond au temps entre deux battements de cœurs (en millisecondes)\n\n:stopwatch: correspond au temps que met le client a calculer le ping (en millisecondes)\n\n:heartbeat: correspond au temps que met le client a réagir au messages (en millisecondes)")) else: now = int(round(time.time() * 1000)) ping = now - int(round(ctx.message.created_at.timestamp() * 1000)) embed = discord.Embed(description = 'Pinging...') message = await ctx.send(embed = embed) ping2 = int(round(time.time() * 1000)) - now - await message.edit(embed = discord.Embed(color = randint(0, 0xFFFFFF), description = f':hourglass: {round(self.client.latency * 1000)}ms\n\n:stopwatch: {ping2}ms\n\n:heartbeat: {ping}ms')) + await message.edit(embed = discord.Embed(color = discord.Colour.random(), description = f':hourglass: {round(self.client.latency * 1000)}ms\n\n:stopwatch: {ping2}ms\n\n:heartbeat: {ping}ms')) await ctx.message.add_reaction(emoji = '✅') @commands.command(name='avatar') @@ -38,7 +38,7 @@ class Utils(commands.Cog): else: user = self.client.get_user(int(user[2:-1].replace("!",""))) await ctx.message.add_reaction(emoji = '✅') - embed = discord.Embed(description = f"[lien vers la photo de profil]({user.avatar_url}) de {user.mention}", color = randint(0, 0xFFFFFF)) + embed = discord.Embed(description = f"[lien vers la photo de profil]({user.avatar_url}) de {user.mention}", color = discord.Colour.random()) embed.set_author(name = f"Photo de profil de {user.name}") embed.set_image(url = user.avatar_url) await ctx.send(embed = embed) @@ -74,7 +74,7 @@ class Utils(commands.Cog): answer = str(round(float(answer),2)) equation = f"'{equation}' arrondi à 2" equation = equation.replace('*', '×').replace('/', '÷').replace('>=', '≥').replace('<=', '≤') - embed = discord.Embed(color = randint(0, 0xFFFFFF), title = 'Calculatrice') + embed = discord.Embed(color = discord.Colour.random(), title = 'Calculatrice') embed.set_footer(text = ctx.author) embed.add_field(name = 'Calcul :', value = equation, inline = False) @@ -142,7 +142,7 @@ class Utils(commands.Cog): return await ctx.send("Ta note doit faire moins de 2048 caractères.") else: await ctx.message.delete() - embed = discord.Embed(description = text, color = randint(0, 0xFFFFFF)) + embed = discord.Embed(description = text, color = discord.Colour.random()) embed.set_author(name = f"Mémo noté depuis {ctx.guild.name}", icon_url = ctx.author.avatar_url) embed.set_footer(text = f'📝 le {datetime.now(pytz.timezone("Europe/Paris")).strftime("%d/%m/%Y à %H:%M:%S")}') await ctx.author.send(embed = embed) @@ -157,7 +157,7 @@ class Utils(commands.Cog): """Donne des infos sur le bot.\n ➡ Syntaxe: .infos/info⁢""" appinfo = await self.client.application_info() - embed = discord.Embed(color = randint(0, 0xFFFFFF)) + embed = discord.Embed(color = discord.Colour.random()) embed.set_author(name = appinfo.name, icon_url = self.client.user.avatar_url) @@ -209,25 +209,25 @@ class Utils(commands.Cog): """Affiche la carte voulue d'Among Us.⁢⁢⁢⁢⁢\n ➡ Syntaxe: .amongus ⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" if map.lower() in self._map_list_among_us("mira"): image = "https://i.imgur.com/6ijrH1h.jpg" - embed = discord.Embed(title = f"Map Mira HQ d'Among Us", color = randint(0, 0xFFFFFF), description = f"[lien de l'image]({image})") + embed = discord.Embed(title = f"Map Mira HQ d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed.set_image(url = image) await ctx.send(embed = embed) await ctx.message.add_reaction(emoji = '✅') elif map.lower() in self._map_list_among_us("polus"): image = "https://i.imgur.com/mhFmcw3.jpg" - embed = discord.Embed(title = f"Map Polus d'Among Us", color = randint(0, 0xFFFFFF), description = f"[lien de l'image]({image})") + embed = discord.Embed(title = f"Map Polus d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed.set_image(url = image) await ctx.send(embed = embed) await ctx.message.add_reaction(emoji = '✅') elif map.lower() in self._map_list_among_us("skeld"): image = "https://i.imgur.com/OSXI4Zv.jpg" - embed = discord.Embed(title = f"Map The Skeld d'Among Us", color = randint(0, 0xFFFFFF), description = f"[lien de l'image]({image})") + embed = discord.Embed(title = f"Map The Skeld d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed.set_image(url = image) await ctx.send(embed = embed) await ctx.message.add_reaction(emoji = '✅') elif map.lower() in self._map_list_among_us("airship"): image = "https://i.imgur.com/CYbPlQ6.png" - embed = discord.Embed(title = f"Map Airship d'Among Us", color = randint(0, 0xFFFFFF), description = f"[lien de l'image]({image})") + embed = discord.Embed(title = f"Map Airship d'Among Us", color = discord.Colour.random(), description = f"[lien de l'image]({image})") embed.set_image(url = image) await ctx.send(embed = embed) await ctx.message.add_reaction(emoji = '✅') @@ -243,7 +243,7 @@ class Utils(commands.Cog): nom = f"{user[0].name}#{user[0].discriminator}" if user[0].nick: nom = f"{user[0].nick} ({user[0].name}#{user[0].discriminator})" - embed = discord.Embed(color = randint(0, 0xFFFFFF)).set_author(name = nom, icon_url = user[0].avatar_url) + embed = discord.Embed(color = discord.Colour.random()).set_author(name = nom, icon_url = user[0].avatar_url) embed.add_field(name = "ID", value = user[0].id) @@ -328,7 +328,7 @@ class Utils(commands.Cog): shuffle(emojis_chosen) for i in range(len(args[1:])): 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 = discord.Colour.random()).set_footer(text = self.user_or_nick(ctx.author), icon_url = ctx.author.avatar_url) sondage = await ctx.send(embed = embed) for i in range(len(args[1:])): await sondage.add_reaction(emoji = emojis_chosen[i])