Defining Constants in variables for it to be more modular

Turning repeated code into functions
pull/4/head
sgoudham 4 years ago
parent b86aa2a576
commit b3bc25761e

@ -18,6 +18,16 @@ anime = {"yumeko": "Jabami Yumeko",
} }
# Gets the member and user avatar
def getMember(msg):
# Set member as the author
member = msg.author
# Get the member avatar
userAvatar = member.avatar_url
return member, userAvatar
# Function to turn the user inputted name into the full name # Function to turn the user inputted name into the full name
def Abbrev(anime_msg): def Abbrev(anime_msg):
# Get the lowercase # Get the lowercase
@ -41,10 +51,8 @@ def randomWaifu(msg, waifu):
with open(f'images/AnimeImages/Waifus/{random.choice(waifu)}.txt') as file: with open(f'images/AnimeImages/Waifus/{random.choice(waifu)}.txt') as file:
array = file.readlines() array = file.readlines()
# Set member as the author # Get the member and the userAvatar
member = msg.author member, userAvatar = getMember(msg)
# Get the member's avatar
userAvatar = member.avatar_url
# Set up the embed for a random waifu image # Set up the embed for a random waifu image
waifu_embed = Embed( waifu_embed = Embed(
@ -63,10 +71,8 @@ def randomHusbando(msg, husbando):
with open(f'images/AnimeImages/Husbandos/{random.choice(husbando)}.txt') as file: with open(f'images/AnimeImages/Husbandos/{random.choice(husbando)}.txt') as file:
array = file.readlines() array = file.readlines()
# Set member as the author # Get the member and the userAvatar
member = msg.author member, userAvatar = getMember(msg)
# Get the member's avatar
userAvatar = member.avatar_url
# Set up the embed for a random husbando image # Set up the embed for a random husbando image
husbando_embed = Embed( husbando_embed = Embed(
@ -81,10 +87,8 @@ def randomHusbando(msg, husbando):
# Function to allow modular code and sets up the embed for the anime images # Function to allow modular code and sets up the embed for the anime images
def displayAnimeImage(array, msg, name): def displayAnimeImage(array, msg, name):
# Set member as the author # Get the member and the userAvatar
member = msg.author member, userAvatar = getMember(msg)
# Get the member's avatar
userAvatar = member.avatar_url
# Set up embed for an image relating to a husbando or waifu # Set up embed for an image relating to a husbando or waifu
anime_embed = Embed( anime_embed = Embed(

Loading…
Cancel
Save