diff options
author | 2019-02-14 18:20:06 +0530 | |
---|---|---|
committer | 2019-02-14 18:20:06 +0530 | |
commit | ebf643601422e816f46203b1f789b26abd0b06e6 (patch) | |
tree | d1c65fd87902a4b4f820b2a02ce58067679e232f | |
parent | Well i have done quite a few changes : (diff) |
I have made the following changes :
1)I have re check my json file and formated the poems.
2)I have now loaded the json data when the cog extension is loaded insted of loading it per command.
3)Fixed the indentation in the comments/doc strings.(making 1st letter capital and adding a period at the end)
4)Changed double new lines to single new line between text statements.
5)changed the double new line to single new line between the imports.
-rw-r--r-- | bot/resources/valentines/bemyvalentine_valentines.json | 25 | ||||
-rw-r--r-- | bot/seasons/valentines/be_my_valentine.py | 75 |
2 files changed, 44 insertions, 56 deletions
diff --git a/bot/resources/valentines/bemyvalentine_valentines.json b/bot/resources/valentines/bemyvalentine_valentines.json index 45c3939d..17db8ad1 100644 --- a/bot/resources/valentines/bemyvalentine_valentines.json +++ b/bot/resources/valentines/bemyvalentine_valentines.json @@ -1,35 +1,34 @@ { "valentine_poems": [ { - "message" :"If you were my rose,\nthen I'd be your sun,painting you rainbows when the rains come.\nI'd change my orbit to banish the night,as to keep you in my nurturing light." - + "message" :"If you were my rose,\nthen I'd be your sun,\npainting you rainbows when the rains come.\nI'd change my orbit to banish the night,\nas to keep you in my nurturing light." }, { - "message" :"If you were my world, then I'd be your moon,\nyour silent protector, a night-light in the gloom.\nOur fates intertwined, two bodies in motionthrough time and space,\n our dance of devotion." + "message" :"If you were my world, then I'd be your moon,\nyour silent protector, a night-light in the gloom.\nOur fates intertwined, two bodies in motion through time and space,\nour dance of devotion." }, { "message" :"If you were my island, then I'd be your sea,\ncaressing your shores, soft and gentle I'd be.\nMy tidal embrace would leave gifts on your sands,\nbut by current and storm, I'd ward your gentle lands." }, { - "message" :"If you were love's promise, then I would be time,\nyour constant companion till stars align.And though we are mere mortals,\n true love is divine,and my devotion eternal,\n to my one valentine." + "message" :"If you were love's promise, then I would be time,\nyour constant companion till stars align. And though we are mere mortals,\ntrue love is divine,and my devotion eternal,\nto my one valentine." }, { - "message" :"Have I told you, Valentine,That I’m all wrapped up in you?\nMy feelings for you bring to me A joy I never knew. \n \n You light up everything for me;In my heart you shine;\nIlluminating my whole life,My darling Valentine." + "message" :"Have I told you,\nValentine, That I’m all wrapped up in you?\nMy feelings for you bring to me A joy I never knew.\n \n You light up everything for me; In my heart you shine;\nIlluminating my whole life,\nMy darling Valentine." }, { - "message" :"My days are filled with yearning;\nMy nights are full of dreams.\nI’m always thinking of you;\nI’m in a trance, it seems.\n\n You’re all I ever wanted;\nI wish you could be mine;\nAnd so I have to ask you:Will you be my Valentine?" + "message" :"My days are filled with yearning;\nMy nights are full of dreams.\nI’m always thinking of you;\nI’m in a trance, it seems.\n\n You’re all I ever wanted;\nI wish you could be mine;\nAnd so I have to ask you: Will you be my Valentine?" }, { - "message" :"My Valentine, I love just you;\nMy devotion I declare.\nI’ll spend my life looking for ways To show you that I care. \n\nPlease say you feel the same for me;\nSay you’ll be forever mine;\nWe’ll share a life of happiness,\n My treasured Valentine." + "message" :"My Valentine, I love just you;\nMy devotion I declare.\nI’ll spend my life looking for ways To show you that I care.\n\nPlease say you feel the same for me;\nSay you’ll be forever mine;\nWe’ll share a life of happiness,\nMy treasured Valentine." }, { - "message" :"Every day with you is Valentine's Day, my love.\nEvery day is filled with romance, with love, with sharing and caring.\nEvery day I am reminded how blessed I am to have you as my \nValentine, my sweetheart, my lover, my friend, my playmate, my companion.\nNo Valentine card, no words at all could express how much I love You,\n how ecstatic I feel to know that you are mine.My Valentine, every day,\n I'll try to show you that every day I love you more." + "message" :"Every day with you is Valentine's Day, my love.\nEvery day is filled with romance, with love, with sharing and caring.\nEvery day I am reminded how blessed I am to have you as my,\nValentine, my sweetheart, my lover, my friend, my playmate, my companion.\nNo Valentine card, no words at all could express how much I love You,\nhow ecstatic I feel to know that you are mine.\nMy Valentine, every day,\nI'll try to show you that every day I love you more." }, { - "message" :"I lucked out when I met you, sweet thing.\nYou've brought richness to each day I exist.\nYou fill my days with the excitement of love,\n And you have since the moment we kissed.\nSo I celebrate Valentine's Day with you,\nWith a love that will always stay fresh and new." + "message" :"I lucked out when I met you, sweet thing.\nYou've brought richness to each day I exist.\nYou fill my days with the excitement of love,\nAnd you have since the moment we kissed.\nSo I celebrate Valentine's Day with you,\nWith a love that will always stay fresh and new." }, { - "message" :"You are my everything, Valentine.\nAs a desert creature longs for water, my thirst for you can never be slaked.\nIn a ho-hum day dragging on, thoughts of you bring excitement, joy and pleasure.\nAs a child opens the birthday gift he most wanted, I see everything I want in you.\nYou are my everything, Valentine." + "message" :"You are my everything, Valentine.\nAs a desert creature longs for water, my thirst for you can never be slaked.\nIn a ho-hum day dragging on, thoughts of you bring excitement, joy and pleasure.\nAs a child opens the birthday gift he most wanted,\nI see everything I want in you.\nYou are my everything, Valentine." }, { "message" :"My love for you is like the raging sea,\nSo powerful and deep it will forever be.\nThrough storm, wind, and heavy rain, It will withstand every pain.\nOur hearts are so pure and love so sweet.\nI love you more with every heartbeat!" @@ -38,19 +37,19 @@ "message" :"A million stars up in the sky.\nOne shines brighter - I can't deny.\nA love so precious, a love so true, a love that comes from me to you.\nThe angels sing when you are near.\nWithin your arms I have nothing to fear.\nYou always know just what to say.\nJust talking to you makes my day.\nI love you, honey, with all of my heart.\nTogether forever and never to part." }, { - "message" :"What do I do,\nWhen I'm still in love with you?You walked away, 'Cause you didn't want to stay.You broke my heart, you tore me apart.\nEvery day I wait for you, Telling myself our love was true.\nBut when you don't show, more tears start to flow.\nThat's when I knowI have to let go." + "message" :"What do I do,\nWhen I'm still in love with you?\nYou walked away, Cause you didn't want to stay.\nYou broke my heart, you tore me apart.\nEvery day I wait for you, Telling myself our love was true.\nBut when you don't show, more tears start to flow.\nThat's when I know I have to let go." }, { "message" :"When I say I love you, please believe it's true.\nWhen I say forever, know I'll never leave you.\nWhen I say goodbye, promise me you won't cry,\nBecause the day I'll be saying that will be the day I die." }, { - "message" :"Beauty isn't seen by eyes.\nIt's felt by hearts,\nRecognized by souls, In the presence of love." + "message" :"Beauty isn't seen by eyes.\nIt's felt by hearts,\nRecognized by souls,\nIn the presence of love." }, { "message" :"L is for \"laughter\" we had along the way.\nO is for \"optimism\" you gave me every day.\nV is for \"value\" of being my best friend.\nE is for \"eternity,\" a love that has no end." }, { - "message" :"If roses were red and violets could be blue,\nI'd take us away to a place just for two.\nYou'd see my true colors and all that I felt.\nI'd see that you could love me and nobody else.\nWe'd build ourselves a fortress where we'd run and play.\nYou'd be mine and I'd be yours 'til our dying day.\nThen I wake and realize you were never here.\nIt's all just my thoughts, my dreams, my hopes...But now it's only tears!" + "message" :"If roses were red and violets could be blue,\nI'd take us away to a place just for two.\nYou'd see my true colors and all that I felt.\nI'd see that you could love me and nobody else.\nWe'd build ourselves a fortress where we'd run and play.\nYou'd be mine and I'd be yours till our dying day.\nThen I wake and realize you were never here.\nIt's all just my thoughts, my dreams, my hopes...\nBut now it's only tears!" } ], "valentine_compliments": [ diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index e032a593..ad543315 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -4,7 +4,6 @@ import typing from json import load from pathlib import Path - import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType @@ -17,11 +16,13 @@ HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_hea EMOJI_1 = random.choice(HEART_EMOJIS) EMOJI_2 = random.choice(HEART_EMOJIS) USER_LOVEFEST = [] +JSON_FILE = open(Path('bot', 'resources', 'VALENTINES', 'bemyvalentine_valentines.json'), 'r', encoding="utf8") +VALENTINES = load(JSON_FILE) class BeMyValentine: """ - A cog that sends valentines to other users ! + A cog that sends VALENTINES to other users ! """ id = Lovefest.role_id @@ -31,7 +32,7 @@ class BeMyValentine: @commands.command(name="lovefest") async def add_role(self, ctx): """ - This command adds people to the lovefest role + This command adds people to the lovefest role. """ user = ctx.author role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) @@ -61,22 +62,16 @@ class BeMyValentine: await ctx.send(embed=embed) @commands.cooldown(1, 1800, BucketType.user) - @commands.group( - name='bemyvalentine', - invoke_without_command=True - ) + @commands.group(name='bemyvalentine', invoke_without_command=True) async def send_valentine(self, ctx, user: typing.Optional[discord.Member] = None, *, valentine_type=None): """ This command sends valentine to user if specified or a random user having lovefest role. - syntax: .bemyvalentine [user](optional) [p/poem/c/compliment/or you can type your own valentine message] (optional) example: .bemyvalentine (sends valentine as a poem or a compliment to a random user) - example: .bemyvalentine @Iceman#6508 p (sends a poem to Iceman) - example: .bemyvalentine @Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman) """ if ctx.guild is None: @@ -132,21 +127,18 @@ class BeMyValentine: @send_valentine.command(name='dm') async def anonymous(self, ctx, user: typing.Optional[discord.Member] = None, *, valentine_type=None): """ - - This command DMs a valentine to be given anonymous to a user if specified or a random user having lovefest role. - - - **This command should be DMed to the bot.** + This command DMs a valentine to be given anonymous to a user if specified or a random user having lovefest role. + **This command should be DMed to the bot.** - syntax : .bemyvalentine dm [user](optional) [p/poem/c/compliment/or you can type your own valentine message] - (optional) - - example : .bemyvalentine dm (sends valentine as a poem or a compliment to a random user in DM making you anonymous) - - example : .bemyvalentine dm Iceman#6508 p (sends a poem to Iceman in DM making you anonymous) + syntax : .bemyvalentine dm [user](optional) [p/poem/c/compliment/or you can type your own valentine message] + (optional) - example : .bemyvalentine dm Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman in - DM making you anonymous) + example : .bemyvalentine dm (sends valentine as a poem or a compliment to a random user in DM making you + anonymous) + example : .bemyvalentine dm Iceman#6508 p (sends a poem to Iceman in DM making you anonymous) + example : .bemyvalentine dm Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman + in DM making you anonymous) """ if ctx.guild is not None: # This command is only DM specific @@ -198,38 +190,35 @@ class BeMyValentine: @staticmethod def random_valentine(): """ - grabs a random poem or a compliment (any message) + Grabs a random poem or a compliment (any message). """ - with open(Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json'), 'r', encoding="utf8") as f: - valentines = load(f) - valentine_poem = random.choice(valentines['valentine_poems']) - valentine_compliment = random.choice(valentines['valentine_compliments']) - random_valentine = random.choice([valentine_compliment, valentine_poem]) - if random_valentine == valentine_poem: - message_type = 'A poem dedicated to' - else: - message_type = 'A compliment for ' - return random_valentine['message'], message_type + valentine_poem = random.choice(VALENTINES['valentine_poems']) + valentine_compliment = random.choice(VALENTINES['valentine_compliments']) + JSON_FILE.close() + random_valentine = random.choice([valentine_compliment, valentine_poem]) + if random_valentine == valentine_poem: + message_type = 'A poem dedicated to' + else: + message_type = 'A compliment for ' + return random_valentine['message'], message_type @staticmethod def valentine_poem(): """ - grabs a random poem + Grabs a random poem. """ - with open(Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json'), 'r', encoding="utf8") as f: - valentines = load(f) - valentine_poem = random.choice(valentines['valentine_poems']) - return valentine_poem['message'] + valentine_poem = random.choice(VALENTINES['valentine_poems']) + JSON_FILE.close() + return valentine_poem['message'] @staticmethod def valentine_compliment(): """ - grabs a random compliment + Grabs a random compliment. """ - with open(Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json'), 'r', encoding="utf8") as f: - valentines = load(f) - valentine_compliment = random.choice(valentines['valentine_compliments']) - return valentine_compliment['message'] + valentine_compliment = random.choice(VALENTINES['valentine_compliments']) + JSON_FILE.close() + return valentine_compliment['message'] def setup(bot): |