From 5ebd48de26bce64b17dc011184c22b1e8a29eee0 Mon Sep 17 00:00:00 2001 From: Rohan Date: Tue, 12 Feb 2019 13:18:58 +0530 Subject: im done working with the bemyvalentine command --- .../valentines/bemyvalentine_valentines.json | 110 +++++++++++ bot/seasons/valentines/be_my_valentine.py | 209 +++++++++++++++++++++ 2 files changed, 319 insertions(+) create mode 100644 bot/resources/valentines/bemyvalentine_valentines.json create mode 100644 bot/seasons/valentines/be_my_valentine.py (limited to 'bot') diff --git a/bot/resources/valentines/bemyvalentine_valentines.json b/bot/resources/valentines/bemyvalentine_valentines.json new file mode 100644 index 00000000..45c3939d --- /dev/null +++ b/bot/resources/valentines/bemyvalentine_valentines.json @@ -0,0 +1,110 @@ +{ + "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 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 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" :"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" :"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" :"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" :"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" :"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" :"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!" + }, + { + "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" :"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" :"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!" + } + ], + "valentine_compliments": [ + { + "message": "To the love of my life. I’m the luckiest person on Earth because I have you! I adore you!You’ve taught me the best thing to hold onto in life is each other.You are my sweetheart, you are my life, you are my everything." + }, + { + "message": "It was a million tiny little things that, when you added them all up, they meant we were supposed to be together." + }, + { + "message": "when you smile, the whole world stops and stares for a while, cause you're amazing, just the way you ar" + }, + { + "message": "Take love, multiply it by infinity and take it to the depths of forever... and you still have only a glimpse of how I feel for you." + }, + { + "message": "When you kiss me, the world just melts away. When you hold me in your arms, I feel safe. Being in love with you has made me see how wonderful life can be. I love you. " + }, + { + "message": "No matter how dark the days get, you still know how to make me smile and Even after all this time, you still take my breath away. " + }, + { + "message": "I don't know what my future holds but I know I want you in it but I would travel to the moon and back just to see you smile." + }, + { + "message": "I may not always say it but know that With every breath in my body and every beat of my heart I know I will always love you. " + }, + { + "message": "And darling I will be loving you 'til we're 70. And baby my heart could still fall as hard at 23. And I'm thinking 'bout how people fall in love in mysterious ways. Maybe just the touch of a hand. Oh me, I fall in love with you every single day. And I just wanna tell you I am. So honey now. Take me into your loving arms. Kiss me under the light of a thousand stars. Place your head on my beating heart. I'm thinking out loud. Maybe we found love right where we are." + }, + { + "message": "I love you. I knew it the minute I met you. I'm sorry it took so long for me to catch up. I just got stuck." + }, + { + "message": "You are truly beautiful from within. I am serious! It's not just about how pretty you are (which you are, of course), but you have a beautiful heart." + }, + { + "message": "If you could see yourself through my eyes, you would know how much I love you. You hold a very special place in my heart! I will love you forever!" + }, + { + "message": "I don’t need a thousand reasons to feel special. All I need is you to live in this world. You are the sunshine of my life." + }, + { + "message": "I wish to be everything that brings a smile on your face and happiness in your heart. I want to love you like no else ever did!" + }, + { + "message": "Every morning of my life gives you a new reason to love you and to appreciate you for what you’ve given me. You are the one that holds the key to my heart!" + }, + { + "message": "Each time I look at you, I just smile to myself and think, ‘I certainly could not have done better’. You are perfect the way you are. I love you honey." + }, + { + "message": "Look at the computer keyboard, U and I were placed side by side. That’s how the alphabets should be arranged because my love will never cease to exist as long as it’s you and me." + } + ] + +} \ No newline at end of file diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py new file mode 100644 index 00000000..35ced8d0 --- /dev/null +++ b/bot/seasons/valentines/be_my_valentine.py @@ -0,0 +1,209 @@ +import logging +import random +import typing +from json import load +from pathlib import Path + + +import discord +from discord.ext import commands +from discord.ext.commands.cooldowns import BucketType + +from bot.constants import Colours, Lovefest + +log = logging.getLogger(__name__) + +HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] +EMOJI_1 = random.choice(HEART_EMOJIS) +EMOJI_2 = random.choice(HEART_EMOJIS) + + +class BeMyValentine: + """ + A cog that sends valentines to other users ! + """ + id = Lovefest.role_id + + def __init__(self, bot): + self.bot = bot + + @commands.command(name="lovefest") + async def add_role(self, ctx): + """ + This command adds people to the lovefest role + """ + user = ctx.author + role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) + if id not in [role.id for role in ctx.message.author.roles]: + await user.add_roles(role) + await ctx.send("The Lovefest role has been added !") + else: + await ctx.send("You already have the role !") + + @commands.cooldown(1, 1800, BucketType.user) + @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) + """ + channel = self.bot.get_channel(Lovefest.channel_id) + random_user = [] + + if user == ctx.author: + await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + + elif user is None: + for member in ctx.guild.members: + for role in member.roles: + if role.id == Lovefest.role_id: + random_user.append(member) + user = random.choice(random_user) + + if valentine_type is None: + # grabs a random valentine -can be a poem or a good message + valentine, title = self.random_valentine() + embed = discord.Embed( + title=f"{EMOJI_1} {title} {user.display_name}{EMOJI_2}", + color=Colours.pink + ) + + elif valentine_type in ['p', 'poem']: + valentine = self.valentine_poem() + embed = discord.Embed( + title=f"{EMOJI_1} A poem dedicated to {user.display_name}{EMOJI_2}", + color=Colours.pink + ) + + elif valentine_type in ['c', 'compliment']: + valentine = self.valentine_compliment() + embed = discord.Embed( + title=f"{EMOJI_1} A compliment for {user.display_name}{EMOJI_2}", + color=Colours.pink + ) + else: + # in this case, the user decides to type his own valentine. + valentine = valentine_type + embed = discord.Embed( + title=f'{EMOJI_1}A message for {user.display_name}{EMOJI_2}', + color=Colours.pink + ) + + embed.description = f'{valentine} \n **{EMOJI_2}From {ctx.author}{EMOJI_1}**' + await channel.send(user.mention, embed=embed) + + @commands.cooldown(1, 1800, BucketType.user) + @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.** + + + 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) + + example : .bemyvalentine dm Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman in + DM making you anonymous) + """ + random_user = [] + + if user == ctx.author: + await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + + elif user is None: + for member in ctx.guild.members: + for role in member.roles: + if role.id == Lovefest.role_id: + random_user.append(member) + user = random.choice(random_user) + + if valentine_type is None: + valentine, title = self.random_valentine() + embed = discord.Embed( + title=f"{EMOJI_1} {title} {user.display_name}{EMOJI_2}", + color=Colours.pink + ) + + elif valentine_type in ['p', 'poem']: + valentine = self.valentine_poem() + embed = discord.Embed( + title=f"{EMOJI_1} A poem dedicated to {user.display_name}{EMOJI_2}", + color=Colours.pink + ) + + elif valentine_type in ['c', 'compliment']: + valentine = self.valentine_compliment() + embed = discord.Embed( + title=f"{EMOJI_1} A compliment for {user.display_name}{EMOJI_1}", + color=Colours.pink + ) + else: + # in this case, the user decides to type his own valentine. + valentine = valentine_type + embed = discord.Embed( + title=f'{EMOJI_1}A message for {user.display_name}{EMOJI_2}', + color=Colours.pink + ) + + embed.description = f'{valentine} \n **{EMOJI_2}From anonymous{EMOJI_1}**' + await user.send(embed=embed) + + @staticmethod + def random_valentine(): + """ + 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 + + @staticmethod + def valentine_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'] + + @staticmethod + def valentine_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'] + + +def setup(bot): + bot.add_cog(BeMyValentine(bot)) + log.debug("Be My Valentine cog loaded") -- cgit v1.2.3 From 16642ebe29690eba15c592f6c153fbc4abfa4348 Mon Sep 17 00:00:00 2001 From: Rohan Date: Wed, 13 Feb 2019 11:18:04 +0530 Subject: Well i have done quite a few changes : 1) I have now made a USER_LOVEFEST list which will have all the members having the lovefest role.Whenever people use the command '.lovefest' to get themselfs the lovefest role,their name will be appended to the list. 2) incase the bot goes offline for some reason,then we need to again add members to USER_LOVEFEST list.So for this i added one more command called '.refreshlovefest' which adds all the members having lovefest role to the list 3) Basically the purpus of the USER_LOVEFEST list is when someone uses the bemyvalentine commands,and they dont provide a user,then a random user is selected from the USER_LOVEFEST list. these are the changes done . --- bot/seasons/valentines/be_my_valentine.py | 52 ++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 12 deletions(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 35ced8d0..e032a593 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -16,6 +16,7 @@ log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] EMOJI_1 = random.choice(HEART_EMOJIS) EMOJI_2 = random.choice(HEART_EMOJIS) +USER_LOVEFEST = [] class BeMyValentine: @@ -35,11 +36,30 @@ class BeMyValentine: user = ctx.author role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) if id not in [role.id for role in ctx.message.author.roles]: + USER_LOVEFEST.append(ctx.author) await user.add_roles(role) await ctx.send("The Lovefest role has been added !") else: await ctx.send("You already have the role !") + @commands.command(name='refreshlovefest') + async def refresh_user_lovefestlist(self, ctx): + """ + Use this command to refresh the USER_VALENTINE list when the bot goes offline and then comes back online + """ + USER_LOVEFEST.clear() + for member in ctx.guild.members: + for role in member.roles: + if role.id == Lovefest.role_id: + USER_LOVEFEST.append(member) + embed = discord.Embed( + title="USER_LOVEFEST list updated!", + description=f'''The USER_LOVEFEST has been refreshed,`bemyvalentine` and `bemyvalentine dm` commands can now + be used and there are {USER_LOVEFEST.__len__()} members having the lovefest role.''', + color=Colours.pink + ) + await ctx.send(embed=embed) + @commands.cooldown(1, 1800, BucketType.user) @commands.group( name='bemyvalentine', @@ -59,18 +79,22 @@ class BeMyValentine: example: .bemyvalentine @Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman) """ + if ctx.guild is None: + # This command should only be used in the server + msg = "You are supposed to use this command in the server." + return await ctx.send(msg) + channel = self.bot.get_channel(Lovefest.channel_id) - random_user = [] if user == ctx.author: + # Well a user cant valentine himself/herself. await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') elif user is None: - for member in ctx.guild.members: - for role in member.roles: - if role.id == Lovefest.role_id: - random_user.append(member) - user = random.choice(random_user) + # just making sure that the random does not pick up the same user(ctx.author) + USER_LOVEFEST.remove(ctx.author) + user = random.choice(USER_LOVEFEST) + USER_LOVEFEST.append(ctx.author) if valentine_type is None: # grabs a random valentine -can be a poem or a good message @@ -124,17 +148,20 @@ class BeMyValentine: example : .bemyvalentine dm Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman in DM making you anonymous) """ - random_user = [] + if ctx.guild is not None: + # This command is only DM specific + msg = "You are not supposed to use this command in the server, DM the command to the bot." + return await ctx.send(msg) if user == ctx.author: + # Well a user cant valentine himself/herself. await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') elif user is None: - for member in ctx.guild.members: - for role in member.roles: - if role.id == Lovefest.role_id: - random_user.append(member) - user = random.choice(random_user) + # just making sure that the random dosent pick up the same user(ctx.author) + USER_LOVEFEST.remove(ctx.author) + user = random.choice(USER_LOVEFEST) + USER_LOVEFEST.append(ctx.author) if valentine_type is None: valentine, title = self.random_valentine() @@ -165,6 +192,7 @@ class BeMyValentine: ) embed.description = f'{valentine} \n **{EMOJI_2}From anonymous{EMOJI_1}**' + await ctx.author.send(f"Your message has been sent to {user}") await user.send(embed=embed) @staticmethod -- cgit v1.2.3 From ebf643601422e816f46203b1f789b26abd0b06e6 Mon Sep 17 00:00:00 2001 From: Rohan Date: Thu, 14 Feb 2019 18:20:06 +0530 Subject: 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. --- .../valentines/bemyvalentine_valentines.json | 25 ++++---- bot/seasons/valentines/be_my_valentine.py | 75 +++++++++------------- 2 files changed, 44 insertions(+), 56 deletions(-) (limited to 'bot') 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): -- cgit v1.2.3 From e13c1bd3ecc6dafa5c8724591d5f571617d7f293 Mon Sep 17 00:00:00 2001 From: Rohan Date: Thu, 14 Feb 2019 18:31:05 +0530 Subject: I have made the command .refreshlovefest modertaor only using the decorator @with_role --- bot/seasons/valentines/be_my_valentine.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index ad543315..1c387f66 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -8,7 +8,8 @@ import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType -from bot.constants import Colours, Lovefest +from bot.constants import Colours, Lovefest, Roles +from bot.decorators import with_role log = logging.getLogger(__name__) @@ -43,6 +44,7 @@ class BeMyValentine: else: await ctx.send("You already have the role !") + @with_role(Roles.moderator) @commands.command(name='refreshlovefest') async def refresh_user_lovefestlist(self, ctx): """ -- cgit v1.2.3 From d55fde242cc8869b735bf0726f70fe9bde255a20 Mon Sep 17 00:00:00 2001 From: Rohan Date: Fri, 15 Feb 2019 10:31:56 +0530 Subject: The did the follwing changes : > 1)The made a static method to generate random heart emoji > 2)I made a static method to get a random user using lovefest role if the person using the command dosent provide one > 3)i made a valentines attribute in the init method taking in the json data > 4) made the poem and compliment /p/c as case insensitive by using lower() to the user input --- .../valentines/bemyvalentine_valentines.json | 4 +- bot/seasons/valentines/be_my_valentine.py | 190 +++++++++++---------- 2 files changed, 99 insertions(+), 95 deletions(-) (limited to 'bot') diff --git a/bot/resources/valentines/bemyvalentine_valentines.json b/bot/resources/valentines/bemyvalentine_valentines.json index 17db8ad1..66c98adb 100644 --- a/bot/resources/valentines/bemyvalentine_valentines.json +++ b/bot/resources/valentines/bemyvalentine_valentines.json @@ -10,7 +10,7 @@ "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,\ntrue love is divine,and my devotion eternal,\nto my one valentine." + "message" :"If you were love's promise, then I would be time,\nyour constant companion till stars align.\nAnd though we are mere mortals,\ntrue love is divine,and my devotion eternal,\nto my one 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." @@ -34,7 +34,7 @@ "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!" }, { - "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" :"A million stars up in the sky.\nOne shines brighter - I can't deny.\nA love so precious, a love so true,\na 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?\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." diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 1c387f66..060cef3b 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -14,36 +14,47 @@ from bot.decorators import with_role log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -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 - def __init__(self, bot): + def __init__(self, bot, valentines): self.bot = bot + self.valentines = valentines - @commands.command(name="lovefest") + @commands.group(name="lovefest", invoke_without_command=True) async def add_role(self, ctx): """ This command adds people to the lovefest role. """ user = ctx.author role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) - if id not in [role.id for role in ctx.message.author.roles]: + if Lovefest.role_id not in [role.id for role in ctx.message.author.roles]: USER_LOVEFEST.append(ctx.author) await user.add_roles(role) await ctx.send("The Lovefest role has been added !") else: await ctx.send("You already have the role !") + @add_role.command(name="remove") + async def remove_role(self, ctx): + """ + This command removes the lovefest role. + """ + user = ctx.author + role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) + if Lovefest.role_id not in [role.id for role in ctx.message.author.roles]: + await ctx.send("You dont have the lovefest role.") + else: + USER_LOVEFEST.remove(ctx.author) + await user.remove_roles(role) + await ctx.send("The lovefest role has been successfully removed !") + @with_role(Roles.moderator) @commands.command(name='refreshlovefest') async def refresh_user_lovefestlist(self, ctx): @@ -76,6 +87,8 @@ class BeMyValentine: 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) """ + emoji_1, emoji_2 = self.random_emoji() + if ctx.guild is None: # This command should only be used in the server msg = "You are supposed to use this command in the server." @@ -88,42 +101,32 @@ class BeMyValentine: await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') elif user is None: + user = self.random_user(ctx.author) # just making sure that the random does not pick up the same user(ctx.author) - USER_LOVEFEST.remove(ctx.author) - user = random.choice(USER_LOVEFEST) - USER_LOVEFEST.append(ctx.author) - if valentine_type is None: - # grabs a random valentine -can be a poem or a good message - valentine, title = self.random_valentine() - embed = discord.Embed( - title=f"{EMOJI_1} {title} {user.display_name}{EMOJI_2}", - color=Colours.pink - ) - - elif valentine_type in ['p', 'poem']: - valentine = self.valentine_poem() - embed = discord.Embed( - title=f"{EMOJI_1} A poem dedicated to {user.display_name}{EMOJI_2}", - color=Colours.pink - ) - - elif valentine_type in ['c', 'compliment']: - valentine = self.valentine_compliment() - embed = discord.Embed( - title=f"{EMOJI_1} A compliment for {user.display_name}{EMOJI_2}", - color=Colours.pink - ) - else: - # in this case, the user decides to type his own valentine. - valentine = valentine_type - embed = discord.Embed( - title=f'{EMOJI_1}A message for {user.display_name}{EMOJI_2}', - color=Colours.pink - ) - - embed.description = f'{valentine} \n **{EMOJI_2}From {ctx.author}{EMOJI_1}**' - await channel.send(user.mention, embed=embed) + if valentine_type is None: + # grabs a random valentine -can be a poem or a good message + valentine, title = self.random_valentine() + + elif valentine_type.lower() in ['p', 'poem']: + valentine = self.valentine_poem() + title = f'A poem dedicated to' + + elif valentine_type.lower() in ['c', 'compliment']: + valentine = self.valentine_compliment() + title = f'A compliment for' + + else: + # in this case, the user decides to type his own valentine. + valentine = valentine_type + title = f'A message for' + + embed = discord.Embed( + title=f'{emoji_1} {title} {user.display_name} {emoji_2}', + description=f'{valentine} \n **{emoji_2}From {ctx.author}{emoji_1}**', + color=Colours.pink + ) + await channel.send(user.mention, embed=embed) @commands.cooldown(1, 1800, BucketType.user) @send_valentine.command(name='dm') @@ -142,6 +145,7 @@ class BeMyValentine: example : .bemyvalentine dm Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman in DM making you anonymous) """ + emoji_1, emoji_2 = self.random_emoji() if ctx.guild is not None: # This command is only DM specific msg = "You are not supposed to use this command in the server, DM the command to the bot." @@ -151,78 +155,78 @@ class BeMyValentine: # Well a user cant valentine himself/herself. await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') - elif user is None: + if user is None: # just making sure that the random dosent pick up the same user(ctx.author) - USER_LOVEFEST.remove(ctx.author) - user = random.choice(USER_LOVEFEST) - USER_LOVEFEST.append(ctx.author) + user = self.random_user(ctx.author) + + if valentine_type is None: + valentine, title = self.random_valentine() - if valentine_type is None: - valentine, title = self.random_valentine() - embed = discord.Embed( - title=f"{EMOJI_1} {title} {user.display_name}{EMOJI_2}", - color=Colours.pink - ) - - elif valentine_type in ['p', 'poem']: - valentine = self.valentine_poem() - embed = discord.Embed( - title=f"{EMOJI_1} A poem dedicated to {user.display_name}{EMOJI_2}", - color=Colours.pink - ) - - elif valentine_type in ['c', 'compliment']: - valentine = self.valentine_compliment() - embed = discord.Embed( - title=f"{EMOJI_1} A compliment for {user.display_name}{EMOJI_1}", - color=Colours.pink - ) - else: - # in this case, the user decides to type his own valentine. - valentine = valentine_type - embed = discord.Embed( - title=f'{EMOJI_1}A message for {user.display_name}{EMOJI_2}', - color=Colours.pink - ) - - embed.description = f'{valentine} \n **{EMOJI_2}From anonymous{EMOJI_1}**' - await ctx.author.send(f"Your message has been sent to {user}") - await user.send(embed=embed) + elif valentine_type.lower() in ['p', 'poem']: + valentine = self.valentine_poem() + title = f'A poem dedicated to' + + elif valentine_type.lower() in ['c', 'compliment']: + valentine = self.valentine_compliment() + title = f'A compliment for' + + else: + # in this case, the user decides to type his own valentine. + valentine = valentine_type + title = f'A message for' + + embed = discord.Embed( + title=f'{emoji_1}{title} {user.display_name}{emoji_2}', + description=f'{valentine} \n **{emoji_2}From anonymous{emoji_1}**', + color=Colours.pink + ) + await ctx.author.send(f"Your message has been sent to {user}") + await user.send(embed=embed) + + @staticmethod + def random_user(author): + USER_LOVEFEST.remove(author) + user = random.choice(USER_LOVEFEST) + USER_LOVEFEST.append(author) + return user @staticmethod - def random_valentine(): + def random_emoji(): + EMOJI_1 = random.choice(HEART_EMOJIS) + EMOJI_2 = random.choice(HEART_EMOJIS) + return EMOJI_1, EMOJI_2 + + def random_valentine(self): """ Grabs a random poem or a compliment (any message). """ - valentine_poem = random.choice(VALENTINES['valentine_poems']) - valentine_compliment = random.choice(VALENTINES['valentine_compliments']) - JSON_FILE.close() + valentine_poem = random.choice(self.valentines['valentine_poems']) + valentine_compliment = random.choice(self.valentines['valentine_compliments']) random_valentine = random.choice([valentine_compliment, valentine_poem]) if random_valentine == valentine_poem: - message_type = 'A poem dedicated to' + title = 'A poem dedicated to' else: - message_type = 'A compliment for ' - return random_valentine['message'], message_type + title = 'A compliment for ' + return random_valentine['message'], title - @staticmethod - def valentine_poem(): + def valentine_poem(self): """ Grabs a random poem. """ - valentine_poem = random.choice(VALENTINES['valentine_poems']) - JSON_FILE.close() + valentine_poem = random.choice(self.valentines['valentine_poems']) return valentine_poem['message'] - @staticmethod - def valentine_compliment(): + def valentine_compliment(self): """ Grabs a random compliment. """ - valentine_compliment = random.choice(VALENTINES['valentine_compliments']) - JSON_FILE.close() + valentine_compliment = random.choice(self.valentines['valentine_compliments']) return valentine_compliment['message'] def setup(bot): - bot.add_cog(BeMyValentine(bot)) + JSON_FILE = open(Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json'), 'r', encoding="utf8") + valentines = load(JSON_FILE) + bot.add_cog(BeMyValentine(bot, valentines)) + JSON_FILE.close() log.debug("Be My Valentine cog loaded") -- cgit v1.2.3 From 07e83cff64089606226d1cbbe51b2488d342391a Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 17 Feb 2019 09:03:24 +0530 Subject: I did the following changes: 1) made a method to load json files 2) Removed refreshlovefest and made a method to choose a random user whenever needed 3) changed the .bemyvalentine dm to .bemyvalentine secret --- bot/seasons/valentines/be_my_valentine.py | 72 ++++++++++++++++++++----------- 1 file changed, 48 insertions(+), 24 deletions(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 060cef3b..4e83ee84 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -14,7 +14,6 @@ from bot.decorators import with_role log = logging.getLogger(__name__) HEART_EMOJIS = [":heart:", ":gift_heart:", ":revolving_hearts:", ":sparkling_heart:", ":two_hearts:"] -USER_LOVEFEST = [] class BeMyValentine: @@ -23,25 +22,44 @@ class BeMyValentine: """ id = Lovefest.role_id - def __init__(self, bot, valentines): + def __init__(self, bot): self.bot = bot - self.valentines = valentines + self.valentines = self.load_json() + + @staticmethod + def load_json(): + p = Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json') + with p.open() as json_data: + valentines = load(json_data) + return valentines @commands.group(name="lovefest", invoke_without_command=True) + async def lovefest_role(self, ctx): + """ + By using this command, you can have yourself the lovefest role or remove it. + The lovefest role makes you eligible to receive anonymous valentines from other users. + """ + message = """``` +You can have the lovefest role or get rid of it by using one of the commands shown below: +1) use the command \".lovefest sub\" to get the lovefest role. +2) use the command \".lovefest unsub\" to get rid of the lovefest role. + ```""" + await ctx.send(message) + + @lovefest_role.command(name="sub") async def add_role(self, ctx): """ - This command adds people to the lovefest role. + This command adds the lovefest role. """ user = ctx.author role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) if Lovefest.role_id not in [role.id for role in ctx.message.author.roles]: - USER_LOVEFEST.append(ctx.author) await user.add_roles(role) await ctx.send("The Lovefest role has been added !") else: await ctx.send("You already have the role !") - @add_role.command(name="remove") + @lovefest_role.command(name="unsub") async def remove_role(self, ctx): """ This command removes the lovefest role. @@ -51,16 +69,15 @@ class BeMyValentine: if Lovefest.role_id not in [role.id for role in ctx.message.author.roles]: await ctx.send("You dont have the lovefest role.") else: - USER_LOVEFEST.remove(ctx.author) await user.remove_roles(role) await ctx.send("The lovefest role has been successfully removed !") - @with_role(Roles.moderator) + """@with_role(Roles.moderator) @commands.command(name='refreshlovefest') async def refresh_user_lovefestlist(self, ctx): - """ + Use this command to refresh the USER_VALENTINE list when the bot goes offline and then comes back online - """ + USER_LOVEFEST.clear() for member in ctx.guild.members: for role in member.roles: @@ -73,7 +90,7 @@ class BeMyValentine: color=Colours.pink ) await ctx.send(embed=embed) - + """ @commands.cooldown(1, 1800, BucketType.user) @commands.group(name='bemyvalentine', invoke_without_command=True) async def send_valentine(self, ctx, user: typing.Optional[discord.Member] = None, *, valentine_type=None): @@ -101,7 +118,9 @@ class BeMyValentine: await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') elif user is None: - user = self.random_user(ctx.author) + author = ctx.author + members = ctx.guild.members + user = self.random_user(author, members) # just making sure that the random does not pick up the same user(ctx.author) if valentine_type is None: @@ -129,20 +148,20 @@ class BeMyValentine: await channel.send(user.mention, embed=embed) @commands.cooldown(1, 1800, BucketType.user) - @send_valentine.command(name='dm') + @send_valentine.command(name='secret') 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.** - syntax : .bemyvalentine dm [user](optional) [p/poem/c/compliment/or you can type your own valentine message] + syntax : .bemyvalentine secret [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 + example : .bemyvalentine secret (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 + example : .bemyvalentine secret Iceman#6508 p (sends a poem to Iceman in DM making you anonymous) + example : .bemyvalentine secret Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman in DM making you anonymous) """ emoji_1, emoji_2 = self.random_emoji() @@ -156,8 +175,10 @@ class BeMyValentine: await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') if user is None: - # just making sure that the random dosent pick up the same user(ctx.author) - user = self.random_user(ctx.author) + author = ctx.author + members = ctx.guild.members + user = self.random_user(author, members) + # just making sure that the random does not pick up the same user(ctx.author) if valentine_type is None: valentine, title = self.random_valentine() @@ -184,7 +205,13 @@ class BeMyValentine: await user.send(embed=embed) @staticmethod - def random_user(author): + def random_user(author, members): + USER_LOVEFEST = [] + for member in members: + for role in member.roles: + if role.id == Lovefest.role_id: + USER_LOVEFEST.append(member) + USER_LOVEFEST.remove(author) user = random.choice(USER_LOVEFEST) USER_LOVEFEST.append(author) @@ -225,8 +252,5 @@ class BeMyValentine: def setup(bot): - JSON_FILE = open(Path('bot', 'resources', 'valentines', 'bemyvalentine_valentines.json'), 'r', encoding="utf8") - valentines = load(JSON_FILE) - bot.add_cog(BeMyValentine(bot, valentines)) - JSON_FILE.close() + bot.add_cog(BeMyValentine(bot)) log.debug("Be My Valentine cog loaded") -- cgit v1.2.3 From 82ccd2b336dffe028e4c96fd4d13b3140bb715ed Mon Sep 17 00:00:00 2001 From: Rohan Date: Sun, 17 Feb 2019 09:17:59 +0530 Subject: fixed linter issues --- bot/seasons/valentines/be_my_valentine.py | 26 +++----------------------- 1 file changed, 3 insertions(+), 23 deletions(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 4e83ee84..71df78f2 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -8,8 +8,7 @@ import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType -from bot.constants import Colours, Lovefest, Roles -from bot.decorators import with_role +from bot.constants import Colours, Lovefest log = logging.getLogger(__name__) @@ -72,25 +71,6 @@ You can have the lovefest role or get rid of it by using one of the commands sho await user.remove_roles(role) await ctx.send("The lovefest role has been successfully removed !") - """@with_role(Roles.moderator) - @commands.command(name='refreshlovefest') - async def refresh_user_lovefestlist(self, ctx): - - Use this command to refresh the USER_VALENTINE list when the bot goes offline and then comes back online - - USER_LOVEFEST.clear() - for member in ctx.guild.members: - for role in member.roles: - if role.id == Lovefest.role_id: - USER_LOVEFEST.append(member) - embed = discord.Embed( - title="USER_LOVEFEST list updated!", - description=f'''The USER_LOVEFEST has been refreshed,`bemyvalentine` and `bemyvalentine dm` commands can now - be used and there are {USER_LOVEFEST.__len__()} members having the lovefest role.''', - color=Colours.pink - ) - await ctx.send(embed=embed) - """ @commands.cooldown(1, 1800, BucketType.user) @commands.group(name='bemyvalentine', invoke_without_command=True) async def send_valentine(self, ctx, user: typing.Optional[discord.Member] = None, *, valentine_type=None): @@ -161,8 +141,8 @@ You can have the lovefest role or get rid of it by using one of the commands sho example : .bemyvalentine secret (sends valentine as a poem or a compliment to a random user in DM making you anonymous) example : .bemyvalentine secret Iceman#6508 p (sends a poem to Iceman in DM making you anonymous) - example : .bemyvalentine secret Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman - in DM making you anonymous) + example : .bemyvalentine secret Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to + Iceman in DM making you anonymous) """ emoji_1, emoji_2 = self.random_emoji() if ctx.guild is not None: -- cgit v1.2.3 From bfb0161cf4b92fbeaf49174b8b3e7e356202722f Mon Sep 17 00:00:00 2001 From: Rohan Date: Mon, 18 Feb 2019 10:22:52 +0530 Subject: I did the following changes : 1.Lovefest invoke the help cmd. 2.Checks whether the user to whome the valentine should be sent has the lovefest role or not.People who have the lovefest role can only receive valentines. 3.Using role.members insted of guild.members. 4.When choosing a random valentine, if there is no one having the lovefest role,then the bot replies saying that there is no one to send a valentine to.This will be required at the initial stages of this command when in production. --- bot/seasons/valentines/be_my_valentine.py | 78 ++++++++++++++++++------------- 1 file changed, 46 insertions(+), 32 deletions(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 71df78f2..203c2e36 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -8,7 +8,7 @@ import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType -from bot.constants import Colours, Lovefest +from bot.constants import Colours, Lovefest, Client log = logging.getLogger(__name__) @@ -19,7 +19,6 @@ class BeMyValentine: """ A cog that sends valentines to other users ! """ - id = Lovefest.role_id def __init__(self, bot): self.bot = bot @@ -35,15 +34,13 @@ class BeMyValentine: @commands.group(name="lovefest", invoke_without_command=True) async def lovefest_role(self, ctx): """ - By using this command, you can have yourself the lovefest role or remove it. + You can have yourself the lovefest role or remove it. The lovefest role makes you eligible to receive anonymous valentines from other users. - """ - message = """``` -You can have the lovefest role or get rid of it by using one of the commands shown below: -1) use the command \".lovefest sub\" to get the lovefest role. -2) use the command \".lovefest unsub\" to get rid of the lovefest role. - ```""" - await ctx.send(message) + + 1) use the command \".lovefest sub\" to get the lovefest role. + 2) use the command \".lovefest unsub\" to get rid of the lovefest role. + """ + await ctx.invoke(self.bot.get_command("help"), "lovefest") @lovefest_role.command(name="sub") async def add_role(self, ctx): @@ -81,26 +78,35 @@ You can have the lovefest role or get rid of it by using one of the commands sho (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) + example: .bemyvalentine Iceman#6508 p (sends a poem to Iceman) + example: .bemyvalentine Iceman Hey I love you, wanna hang around ? (sends the custom message to Iceman) + NOTE : AVOID TAGGING THE USER MOST OF THE TIMES.JUST TRIM THE '@' when using this command. """ - emoji_1, emoji_2 = self.random_emoji() - if ctx.guild is None: # This command should only be used in the server msg = "You are supposed to use this command in the server." return await ctx.send(msg) - channel = self.bot.get_channel(Lovefest.channel_id) + if user: + if Lovefest.role_id not in [role.id for role in user.roles]: + message = f"You cannot send a valentine to {user} as he/she does not have the lovefest role!" + return await ctx.send(message) if user == ctx.author: # Well a user cant valentine himself/herself. - await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + return await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + + emoji_1, emoji_2 = self.random_emoji() + Role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) + channel = self.bot.get_channel(Lovefest.channel_id) - elif user is None: + if user is None: author = ctx.author - members = ctx.guild.members - user = self.random_user(author, members) + user = self.random_user(author, Role.members) + if user is None: + return await ctx.send("There are no users avilable to whome your valentine can be sent.") + else: + pass # just making sure that the random does not pick up the same user(ctx.author) if valentine_type is None: @@ -144,20 +150,32 @@ You can have the lovefest role or get rid of it by using one of the commands sho example : .bemyvalentine secret Iceman#6508 Hey I love you, wanna hang around ? (sends the custom message to Iceman in DM making you anonymous) """ - emoji_1, emoji_2 = self.random_emoji() if ctx.guild is not None: # This command is only DM specific msg = "You are not supposed to use this command in the server, DM the command to the bot." return await ctx.send(msg) + if user: + if Lovefest.role_id not in [role.id for role in user.roles]: + message = f"You cannot send a valentine to {user} as he/she does not have the lovefest role!" + return await ctx.send(message) + if user == ctx.author: # Well a user cant valentine himself/herself. - await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + return await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + + guild = self.bot.get_guild(id=Client.guild) + emoji_1, emoji_2 = self.random_emoji() + Role = discord.utils.get(guild.roles, id=Lovefest.role_id) + print(Role) if user is None: author = ctx.author - members = ctx.guild.members - user = self.random_user(author, members) + user = self.random_user(author, Role.members) + if user is None: + return await ctx.send("There are no users avilable to whome your valentine can be sent.") + else: + pass # just making sure that the random does not pick up the same user(ctx.author) if valentine_type is None: @@ -186,15 +204,11 @@ You can have the lovefest role or get rid of it by using one of the commands sho @staticmethod def random_user(author, members): - USER_LOVEFEST = [] - for member in members: - for role in member.roles: - if role.id == Lovefest.role_id: - USER_LOVEFEST.append(member) - - USER_LOVEFEST.remove(author) - user = random.choice(USER_LOVEFEST) - USER_LOVEFEST.append(author) + members.remove(author) + if members.__len__() == 0: + user = None + else: + user = random.choice(members) return user @staticmethod -- cgit v1.2.3 From ea30ffd649b49b47d10b0826698e110024f17baa Mon Sep 17 00:00:00 2001 From: Rohan Date: Mon, 18 Feb 2019 10:29:34 +0530 Subject: fixed the linter issue regarding the order of imports --- bot/seasons/valentines/be_my_valentine.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 203c2e36..411bd47b 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -8,7 +8,7 @@ import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType -from bot.constants import Colours, Lovefest, Client +from bot.constants import Client, Colours, Lovefest log = logging.getLogger(__name__) -- cgit v1.2.3 From 1eeb31399fbdb849a4cc3af8d918b8a0cc8edb2b Mon Sep 17 00:00:00 2001 From: Rohan Date: Wed, 20 Feb 2019 20:48:58 +0530 Subject: I did the follow changes: 1.Fixed indentation 2.Removed unneccessory comments 3.Re-named the varible Role to lovefest_role 4.Edited te random user function 5.Removed unneccessory f strings(just removing the f letter,lol) --- bot/seasons/valentines/be_my_valentine.py | 36 +++++++++++++++---------------- 1 file changed, 18 insertions(+), 18 deletions(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 411bd47b..a8554f38 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -39,7 +39,7 @@ class BeMyValentine: 1) use the command \".lovefest sub\" to get the lovefest role. 2) use the command \".lovefest unsub\" to get rid of the lovefest role. - """ + """ await ctx.invoke(self.bot.get_command("help"), "lovefest") @lovefest_role.command(name="sub") @@ -97,17 +97,16 @@ class BeMyValentine: return await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') emoji_1, emoji_2 = self.random_emoji() - Role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) + lovefest_role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) channel = self.bot.get_channel(Lovefest.channel_id) if user is None: author = ctx.author - user = self.random_user(author, Role.members) + user = self.random_user(author, lovefest_role.members) if user is None: return await ctx.send("There are no users avilable to whome your valentine can be sent.") else: pass - # just making sure that the random does not pick up the same user(ctx.author) if valentine_type is None: # grabs a random valentine -can be a poem or a good message @@ -115,16 +114,16 @@ class BeMyValentine: elif valentine_type.lower() in ['p', 'poem']: valentine = self.valentine_poem() - title = f'A poem dedicated to' + title = 'A poem dedicated to' elif valentine_type.lower() in ['c', 'compliment']: valentine = self.valentine_compliment() - title = f'A compliment for' + title = 'A compliment for' else: # in this case, the user decides to type his own valentine. valentine = valentine_type - title = f'A message for' + title = 'A message for' embed = discord.Embed( title=f'{emoji_1} {title} {user.display_name} {emoji_2}', @@ -166,33 +165,31 @@ class BeMyValentine: guild = self.bot.get_guild(id=Client.guild) emoji_1, emoji_2 = self.random_emoji() - Role = discord.utils.get(guild.roles, id=Lovefest.role_id) - print(Role) + lovefest_role = discord.utils.get(guild.roles, id=Lovefest.role_id) if user is None: author = ctx.author - user = self.random_user(author, Role.members) + user = self.random_user(author, lovefest_role.members) if user is None: return await ctx.send("There are no users avilable to whome your valentine can be sent.") else: pass - # just making sure that the random does not pick up the same user(ctx.author) if valentine_type is None: valentine, title = self.random_valentine() elif valentine_type.lower() in ['p', 'poem']: valentine = self.valentine_poem() - title = f'A poem dedicated to' + title = 'A poem dedicated to' elif valentine_type.lower() in ['c', 'compliment']: valentine = self.valentine_compliment() - title = f'A compliment for' + title = 'A compliment for' else: # in this case, the user decides to type his own valentine. valentine = valentine_type - title = f'A message for' + title = 'A message for' embed = discord.Embed( title=f'{emoji_1}{title} {user.display_name}{emoji_2}', @@ -204,11 +201,14 @@ class BeMyValentine: @staticmethod def random_user(author, members): - members.remove(author) - if members.__len__() == 0: - user = None - else: + # just making sure that the random does not pick up the same user(ctx.author) + + if members.__len__() != 0: + if author in members: + members.remove(author) user = random.choice(members) + else: + user = None return user @staticmethod -- cgit v1.2.3 From e793575345d33d8058e2ded36ed76f83bd2bbf66 Mon Sep 17 00:00:00 2001 From: Rohan Date: Thu, 21 Feb 2019 11:54:51 +0530 Subject: Added a function called valentine check which checks if the the valetine that has to be checked needs to be a poe/compliment/custom message. --- .../valentines/bemyvalentine_valentines.json | 2 +- bot/seasons/valentines/be_my_valentine.py | 43 +++++++--------------- 2 files changed, 15 insertions(+), 30 deletions(-) (limited to 'bot') diff --git a/bot/resources/valentines/bemyvalentine_valentines.json b/bot/resources/valentines/bemyvalentine_valentines.json index 66c98adb..89293c29 100644 --- a/bot/resources/valentines/bemyvalentine_valentines.json +++ b/bot/resources/valentines/bemyvalentine_valentines.json @@ -78,7 +78,7 @@ "message": "I may not always say it but know that With every breath in my body and every beat of my heart I know I will always love you. " }, { - "message": "And darling I will be loving you 'til we're 70. And baby my heart could still fall as hard at 23. And I'm thinking 'bout how people fall in love in mysterious ways. Maybe just the touch of a hand. Oh me, I fall in love with you every single day. And I just wanna tell you I am. So honey now. Take me into your loving arms. Kiss me under the light of a thousand stars. Place your head on my beating heart. I'm thinking out loud. Maybe we found love right where we are." + "message": "Darling I will be loving you till we're 70. And baby my heart could still fall as hard at 23. And I'm thinking about how people fall in love in mysterious ways. Maybe just the touch of a hand. Oh me, I fall in love with you every single day. And I just wanna tell you I am. So honey now. Take me into your loving arms. Kiss me under the light of a thousand stars. Place your head on my beating heart. I'm thinking out loud. Maybe we found love right where we are." }, { "message": "I love you. I knew it the minute I met you. I'm sorry it took so long for me to catch up. I just got stuck." diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index a8554f38..c6b9e619 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -82,6 +82,7 @@ class BeMyValentine: example: .bemyvalentine Iceman Hey I love you, wanna hang around ? (sends the custom message to Iceman) NOTE : AVOID TAGGING THE USER MOST OF THE TIMES.JUST TRIM THE '@' when using this command. """ + if ctx.guild is None: # This command should only be used in the server msg = "You are supposed to use this command in the server." @@ -99,31 +100,13 @@ class BeMyValentine: emoji_1, emoji_2 = self.random_emoji() lovefest_role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) channel = self.bot.get_channel(Lovefest.channel_id) + valentine, title = self.valentine_check(valentine_type) if user is None: author = ctx.author user = self.random_user(author, lovefest_role.members) if user is None: return await ctx.send("There are no users avilable to whome your valentine can be sent.") - else: - pass - - if valentine_type is None: - # grabs a random valentine -can be a poem or a good message - valentine, title = self.random_valentine() - - elif valentine_type.lower() in ['p', 'poem']: - valentine = self.valentine_poem() - title = 'A poem dedicated to' - - elif valentine_type.lower() in ['c', 'compliment']: - valentine = self.valentine_compliment() - title = 'A compliment for' - - else: - # in this case, the user decides to type his own valentine. - valentine = valentine_type - title = 'A message for' embed = discord.Embed( title=f'{emoji_1} {title} {user.display_name} {emoji_2}', @@ -149,6 +132,7 @@ class BeMyValentine: example : .bemyvalentine secret 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 msg = "You are not supposed to use this command in the server, DM the command to the bot." @@ -166,15 +150,23 @@ class BeMyValentine: guild = self.bot.get_guild(id=Client.guild) emoji_1, emoji_2 = self.random_emoji() lovefest_role = discord.utils.get(guild.roles, id=Lovefest.role_id) + valentine, title = self.valentine_check(valentine_type) if user is None: author = ctx.author user = self.random_user(author, lovefest_role.members) if user is None: return await ctx.send("There are no users avilable to whome your valentine can be sent.") - else: - pass + embed = discord.Embed( + title=f'{emoji_1}{title} {user.display_name}{emoji_2}', + description=f'{valentine} \n **{emoji_2}From anonymous{emoji_1}**', + color=Colours.pink + ) + await ctx.author.send(f"Your message has been sent to {user}") + await user.send(embed=embed) + + def valentine_check(self, valentine_type): if valentine_type is None: valentine, title = self.random_valentine() @@ -190,14 +182,7 @@ class BeMyValentine: # in this case, the user decides to type his own valentine. valentine = valentine_type title = 'A message for' - - embed = discord.Embed( - title=f'{emoji_1}{title} {user.display_name}{emoji_2}', - description=f'{valentine} \n **{emoji_2}From anonymous{emoji_1}**', - color=Colours.pink - ) - await ctx.author.send(f"Your message has been sent to {user}") - await user.send(embed=embed) + return valentine, title @staticmethod def random_user(author, members): -- cgit v1.2.3 From 85fe1a25c8f71d49427d20e6047c6f80593b4364 Mon Sep 17 00:00:00 2001 From: Rohan Date: Fri, 22 Feb 2019 21:19:50 +0530 Subject: In the json file,i now have a list containing all the peoms/compliments in lists insted of dictionary. --- .../valentines/bemyvalentine_valentines.json | 140 ++++++--------------- bot/seasons/valentines/be_my_valentine.py | 4 +- 2 files changed, 40 insertions(+), 104 deletions(-) (limited to 'bot') diff --git a/bot/resources/valentines/bemyvalentine_valentines.json b/bot/resources/valentines/bemyvalentine_valentines.json index 89293c29..751fe5ef 100644 --- a/bot/resources/valentines/bemyvalentine_valentines.json +++ b/bot/resources/valentines/bemyvalentine_valentines.json @@ -1,109 +1,45 @@ { "valentine_poems": [ - { - "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 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.\nAnd though we are mere mortals,\ntrue love is divine,and my devotion eternal,\nto my one 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 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,\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,\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,\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!" - }, - { - "message" :"A million stars up in the sky.\nOne shines brighter - I can't deny.\nA love so precious, a love so true,\na 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?\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,\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 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!" - } + + "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.", + "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.", + "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.", + "If you were love's promise, then I would be time,\nyour constant companion till stars align.\nAnd though we are mere mortals,\ntrue love is divine,and my devotion eternal,\nto my one valentine.", + "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.", + "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?", + "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.", + "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.", + "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.", + "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.", + "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!", + "A million stars up in the sky.\nOne shines brighter - I can't deny.\nA love so precious, a love so true,\na 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.", + "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.", + "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.", + "Beauty isn't seen by eyes.\nIt's felt by hearts,\nRecognized by souls,\nIn the presence of love.", + "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.", + "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": [ - { - "message": "To the love of my life. I’m the luckiest person on Earth because I have you! I adore you!You’ve taught me the best thing to hold onto in life is each other.You are my sweetheart, you are my life, you are my everything." - }, - { - "message": "It was a million tiny little things that, when you added them all up, they meant we were supposed to be together." - }, - { - "message": "when you smile, the whole world stops and stares for a while, cause you're amazing, just the way you ar" - }, - { - "message": "Take love, multiply it by infinity and take it to the depths of forever... and you still have only a glimpse of how I feel for you." - }, - { - "message": "When you kiss me, the world just melts away. When you hold me in your arms, I feel safe. Being in love with you has made me see how wonderful life can be. I love you. " - }, - { - "message": "No matter how dark the days get, you still know how to make me smile and Even after all this time, you still take my breath away. " - }, - { - "message": "I don't know what my future holds but I know I want you in it but I would travel to the moon and back just to see you smile." - }, - { - "message": "I may not always say it but know that With every breath in my body and every beat of my heart I know I will always love you. " - }, - { - "message": "Darling I will be loving you till we're 70. And baby my heart could still fall as hard at 23. And I'm thinking about how people fall in love in mysterious ways. Maybe just the touch of a hand. Oh me, I fall in love with you every single day. And I just wanna tell you I am. So honey now. Take me into your loving arms. Kiss me under the light of a thousand stars. Place your head on my beating heart. I'm thinking out loud. Maybe we found love right where we are." - }, - { - "message": "I love you. I knew it the minute I met you. I'm sorry it took so long for me to catch up. I just got stuck." - }, - { - "message": "You are truly beautiful from within. I am serious! It's not just about how pretty you are (which you are, of course), but you have a beautiful heart." - }, - { - "message": "If you could see yourself through my eyes, you would know how much I love you. You hold a very special place in my heart! I will love you forever!" - }, - { - "message": "I don’t need a thousand reasons to feel special. All I need is you to live in this world. You are the sunshine of my life." - }, - { - "message": "I wish to be everything that brings a smile on your face and happiness in your heart. I want to love you like no else ever did!" - }, - { - "message": "Every morning of my life gives you a new reason to love you and to appreciate you for what you’ve given me. You are the one that holds the key to my heart!" - }, - { - "message": "Each time I look at you, I just smile to myself and think, ‘I certainly could not have done better’. You are perfect the way you are. I love you honey." - }, - { - "message": "Look at the computer keyboard, U and I were placed side by side. That’s how the alphabets should be arranged because my love will never cease to exist as long as it’s you and me." - } + + "To the love of my life. I’m the luckiest person on Earth because I have you! I adore you!You’ve taught me the best thing to hold onto in life is each other.You are my sweetheart, you are my life, you are my everything.", + "It was a million tiny little things that, when you added them all up, they meant we were supposed to be together.", + "when you smile, the whole world stops and stares for a while, cause you're amazing, just the way you are", + "Take love, multiply it by infinity and take it to the depths of forever... and you still have only a glimpse of how I feel for you.", + "When you kiss me, the world just melts away. When you hold me in your arms, I feel safe. Being in love with you has made me see how wonderful life can be. I love you. ", + "No matter how dark the days get, you still know how to make me smile and Even after all this time, you still take my breath away. ", + "I don't know what my future holds but I know I want you in it but I would travel to the moon and back just to see you smile.", + "I may not always say it but know that With every breath in my body and every beat of my heart I know I will always love you. ", + "Darling I will be loving you till we're 70. And baby my heart could still fall as hard at 23. And I'm thinking about how people fall in love in mysterious ways. Maybe just the touch of a hand. Oh me, I fall in love with you every single day. And I just wanna tell you I am. So honey now. Take me into your loving arms. Kiss me under the light of a thousand stars. Place your head on my beating heart. I'm thinking out loud. Maybe we found love right where we are.", + "I love you. I knew it the minute I met you. I'm sorry it took so long for me to catch up. I just got stuck.", + "You are truly beautiful from within. I am serious! It's not just about how pretty you are (which you are, of course), but you have a beautiful heart.", + "If you could see yourself through my eyes, you would know how much I love you. You hold a very special place in my heart! I will love you forever!", + "I don’t need a thousand reasons to feel special. All I need is you to live in this world. You are the sunshine of my life.", + "I wish to be everything that brings a smile on your face and happiness in your heart. I want to love you like no else ever did!", + "Every morning of my life gives you a new reason to love you and to appreciate you for what you’ve given me. You are the one that holds the key to my heart!", + "Each time I look at you, I just smile to myself and think, ‘I certainly could not have done better’. You are perfect the way you are. I love you honey.", + "Look at the computer keyboard, U and I were placed side by side. That’s how the alphabets should be arranged because my love will never cease to exist as long as it’s you and me." + ] } \ No newline at end of file diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index c6b9e619..163574c3 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -220,14 +220,14 @@ class BeMyValentine: Grabs a random poem. """ valentine_poem = random.choice(self.valentines['valentine_poems']) - return valentine_poem['message'] + return valentine_poem def valentine_compliment(self): """ Grabs a random compliment. """ valentine_compliment = random.choice(self.valentines['valentine_compliments']) - return valentine_compliment['message'] + return valentine_compliment def setup(bot): -- cgit v1.2.3 From 8b19bb2f1b7305ba4cf87ec61cd94ab7ee4b1dd0 Mon Sep 17 00:00:00 2001 From: Scragly <29337040+scragly@users.noreply.github.com> Date: Wed, 27 Feb 2019 18:10:40 +1000 Subject: Address DM failure, random_user logic, str[key] error. --- bot/seasons/valentines/be_my_valentine.py | 23 ++++++++++++++++------- 1 file changed, 16 insertions(+), 7 deletions(-) (limited to 'bot') diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 163574c3..83c02841 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -163,8 +163,12 @@ class BeMyValentine: description=f'{valentine} \n **{emoji_2}From anonymous{emoji_1}**', color=Colours.pink ) - await ctx.author.send(f"Your message has been sent to {user}") - await user.send(embed=embed) + try: + await user.send(embed=embed) + except discord.Forbidden: + await ctx.author.send(f"{user} has DMs disabled, so I couldn't send the message. Sorry!") + else: + await ctx.author.send(f"Your message has been sent to {user}") def valentine_check(self, valentine_type): if valentine_type is None: @@ -186,11 +190,16 @@ class BeMyValentine: @staticmethod def random_user(author, members): - # just making sure that the random does not pick up the same user(ctx.author) + """ + Picks a random member from the list provided in `members`, ensuring + the author is not one of the options. - if members.__len__() != 0: - if author in members: - members.remove(author) + :param author: member who invoked the command + :param members: list of discord.Member objects + """ + if author in members: + members.remove(author) + if len(members) != 0: user = random.choice(members) else: user = None @@ -213,7 +222,7 @@ class BeMyValentine: title = 'A poem dedicated to' else: title = 'A compliment for ' - return random_valentine['message'], title + return random_valentine, title def valentine_poem(self): """ -- cgit v1.2.3 From f96b88b43940726cf21be17601c7cc7a14be1600 Mon Sep 17 00:00:00 2001 From: Scragly <29337040+scragly@users.noreply.github.com> Date: Wed, 27 Feb 2019 18:39:18 +1000 Subject: Address grammatical errors. --- bot/resources/valentines/bemyvalentine_valentines.json | 14 +++++++------- bot/seasons/valentines/be_my_valentine.py | 11 ++++------- 2 files changed, 11 insertions(+), 14 deletions(-) (limited to 'bot') diff --git a/bot/resources/valentines/bemyvalentine_valentines.json b/bot/resources/valentines/bemyvalentine_valentines.json index 751fe5ef..7d5d3705 100644 --- a/bot/resources/valentines/bemyvalentine_valentines.json +++ b/bot/resources/valentines/bemyvalentine_valentines.json @@ -22,14 +22,14 @@ ], "valentine_compliments": [ - "To the love of my life. I’m the luckiest person on Earth because I have you! I adore you!You’ve taught me the best thing to hold onto in life is each other.You are my sweetheart, you are my life, you are my everything.", + "To the love of my life. I’m the luckiest person on Earth because I have you! I adore you! You’ve taught me that the best thing to hold onto in life is each other. You are my sweetheart, you are my life, you are my everything.", "It was a million tiny little things that, when you added them all up, they meant we were supposed to be together.", - "when you smile, the whole world stops and stares for a while, cause you're amazing, just the way you are", + "When you smile, the whole world stops and stares for a while, cause you're amazing, just the way you are.", "Take love, multiply it by infinity and take it to the depths of forever... and you still have only a glimpse of how I feel for you.", - "When you kiss me, the world just melts away. When you hold me in your arms, I feel safe. Being in love with you has made me see how wonderful life can be. I love you. ", - "No matter how dark the days get, you still know how to make me smile and Even after all this time, you still take my breath away. ", - "I don't know what my future holds but I know I want you in it but I would travel to the moon and back just to see you smile.", - "I may not always say it but know that With every breath in my body and every beat of my heart I know I will always love you. ", + "When you kiss me, the world just melts away. When you hold me in your arms, I feel safe. Being in love with you has made me see how wonderful life can be. I love you.", + "No matter how dark the days get, you still know how to make me smile. Even after all this time, you still take my breath away.", + "I don't know what my future holds, but I know I want you in it. I would travel to the moon and back just to see you smile.", + "I may not always say it, but know that with every breath in my body and every beat of my heart I know I will always love you.", "Darling I will be loving you till we're 70. And baby my heart could still fall as hard at 23. And I'm thinking about how people fall in love in mysterious ways. Maybe just the touch of a hand. Oh me, I fall in love with you every single day. And I just wanna tell you I am. So honey now. Take me into your loving arms. Kiss me under the light of a thousand stars. Place your head on my beating heart. I'm thinking out loud. Maybe we found love right where we are.", "I love you. I knew it the minute I met you. I'm sorry it took so long for me to catch up. I just got stuck.", "You are truly beautiful from within. I am serious! It's not just about how pretty you are (which you are, of course), but you have a beautiful heart.", @@ -42,4 +42,4 @@ ] -} \ No newline at end of file +} diff --git a/bot/seasons/valentines/be_my_valentine.py b/bot/seasons/valentines/be_my_valentine.py index 83c02841..0046ceb4 100644 --- a/bot/seasons/valentines/be_my_valentine.py +++ b/bot/seasons/valentines/be_my_valentine.py @@ -94,8 +94,8 @@ class BeMyValentine: return await ctx.send(message) if user == ctx.author: - # Well a user cant valentine himself/herself. - return await ctx.send('Come on dude, you cant send a valentine to yourself :expressionless:') + # Well a user can't valentine himself/herself. + return await ctx.send("Come on dude, you can't send a valentine to yourself :expressionless:") emoji_1, emoji_2 = self.random_emoji() lovefest_role = discord.utils.get(ctx.guild.roles, id=Lovefest.role_id) @@ -199,11 +199,8 @@ class BeMyValentine: """ if author in members: members.remove(author) - if len(members) != 0: - user = random.choice(members) - else: - user = None - return user + + return random.choice(members) if members else None @staticmethod def random_emoji(): -- cgit v1.2.3