From 1b94dd973dccc4994227ee0f15d238631bb3b86d Mon Sep 17 00:00:00 2001 From: Mylloon Date: Wed, 12 May 2021 02:46:04 +0200 Subject: [PATCH] meilleurs commentaires --- src/cogs/internet.py | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/src/cogs/internet.py b/src/cogs/internet.py index 84ad1be..10b5290 100644 --- a/src/cogs/internet.py +++ b/src/cogs/internet.py @@ -31,18 +31,18 @@ class Internet(commands.Cog): await self._cat(await self.client.get_context(message)) @commands.command(name='memes', aliases = ['meme']) - async def _memes(self, ctx, *, args = ""): + async def _memes(self, ctx, *, args = None): """Envois un meme de reddit.\n ➡ Syntaxe: .memes/meme [subreddit]⁢⁢⁢⁢⁢⁢⁢⁢⁢⁢""" + + if args: # s'il y a un subreddit de défini + subredditchoix = args + else: # s'il n'y en a pas + subredditchoix = choice(['memes', 'anime_irl', 'goodanimemes', 'BikiniclienttomTwitter', 'dankmemes', 'DeepFried', + 'educationalmemes', 'funny', 'marvelmemes', 'me_irl', 'meme', 'MemeEconomy', 'Memes_Of_The_Dank', 'MinecraftMemes', + 'physicsmemes', 'reactiongifs', 'blackpeopletwitter', 'metal_me_irl', 'bee_irl', '195', 'shittyadviceanimals', 'meirl', + '2meirl4meirl', 'AdviceAnimals', 'weirdmemes']) + try: - if args != "": # si il y a un arg différent d'un meme - subredditchoix = args - - else: # si il n'y a pas d'arguments - subredditchoix = choice(['memes', 'anime_irl', 'goodanimemes', 'BikiniclienttomTwitter', 'dankmemes', 'DeepFried', - 'educationalmemes', 'funny', 'marvelmemes', 'me_irl', 'meme', 'MemeEconomy', 'Memes_Of_The_Dank', 'MinecraftMemes', - 'physicsmemes', 'reactiongifs', 'blackpeopletwitter', 'metal_me_irl', 'bee_irl', '195', - 'shittyadviceanimals', 'meirl', '2meirl4meirl', 'AdviceAnimals', 'weirdmemes']) - async with Reddit(client_id = os.environ['TOKEN_REDDIT_CLIENT_ID'], client_secret = os.environ['TOKEN_REDDIT_CLIENT_SECRET'], user_agent = f"disreddit /u/{os.environ['TOKEN_REDDIT_USER_AGENT']}, http://localhost:8080") as reddit: subreddit = await reddit.subreddit(subredditchoix) # récupération du subreddit hot = subreddit.top(limit = 20) # récupération des memes avec une limite aux 10 premiers memes @@ -63,7 +63,7 @@ class Internet(commands.Cog): return await message.add_reaction('👎') except Exception as error: - print(f"args: {args}, subreddit: {subredditchoix}, error: {error}") + print(f"Error in _memes command = args: {args}, subreddit: {subredditchoix}, error: {error}") await ctx.message.add_reaction(emoji = '❌') return await ctx.send(f"Ce subreddit est interdit, mis en quarantaine ou n'existe pas. ({subredditchoix})")