From f4edb78591e21ebd793cf0ad703fb6817b3935ee Mon Sep 17 00:00:00 2001 From: sgoudham Date: Sat, 20 Jun 2020 00:35:19 +0100 Subject: [PATCH] Refactored code to make sure 2 config files didn't get messed up --- config.py => Config.py | 0 cogs/Embeds.py | 26 +++++++++++++------------- cogs/FunCommands.py | 6 +++--- cogs/WaifuImages.py | 22 +++++++++++----------- 4 files changed, 27 insertions(+), 27 deletions(-) rename config.py => Config.py (100%) diff --git a/config.py b/Config.py similarity index 100% rename from config.py rename to Config.py diff --git a/cogs/Embeds.py b/cogs/Embeds.py index ee81504d..0a6661c6 100644 --- a/cogs/Embeds.py +++ b/cogs/Embeds.py @@ -6,7 +6,7 @@ import discord from discord.ext import commands from discord.ext.commands import BucketType, cooldown -import config +import Config # Set up the Cog @@ -24,7 +24,7 @@ class Embeds(commands.Cog): try: # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Open the file containing the kissing gifs with open('images/FunCommands/kissing.txt') as file: @@ -39,7 +39,7 @@ class Embeds(commands.Cog): # Set up the embed to display a random kissing gif embed = discord.Embed( title=f" | **{member.display_name}** kissed **{target.display_name}**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(kissing_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -70,7 +70,7 @@ class Embeds(commands.Cog): try: # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Open the file containing the killing gifs with open('images/FunCommands/killing.txt') as file: @@ -85,7 +85,7 @@ class Embeds(commands.Cog): # Set up the embed to display a random killing gif embed = discord.Embed( title=f"<:monkaW:718960264896184380> <:monkaW:718960264896184380> | **{member.display_name}** killed **{target.display_name}**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(killing_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -116,7 +116,7 @@ class Embeds(commands.Cog): try: # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Open the file containing the cuddling gifs with open('images/FunCommands/cuddling.txt') as file: @@ -131,7 +131,7 @@ class Embeds(commands.Cog): # Set up the embed to display a random cuddling gif embed = discord.Embed( title=f"<:blushlook1:677310734123663363> <:blushlook2:679524467248201769> | **{member.display_name}** cuddled **{target.display_name}**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(cuddling_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -162,7 +162,7 @@ class Embeds(commands.Cog): try: # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Open the file containing the cuddling gifs with open('images/FunCommands/slapping.txt') as file: @@ -177,7 +177,7 @@ class Embeds(commands.Cog): # Set up the embed to display a random slapping gif embed = discord.Embed( title=f"<:baka:718942872061083678> <:baka:718942872061083678> | **{member.display_name}** slapped **{target.display_name}**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(slapping_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -208,7 +208,7 @@ class Embeds(commands.Cog): try: # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Open the file containing the patting gifs with open('images/FunCommands/patting.txt') as file: @@ -223,7 +223,7 @@ class Embeds(commands.Cog): # Set up the embed to display a random patting gif embed = discord.Embed( title=f":pleading_face: :pleading_face: | **{member.display_name}** patted **{target.display_name}**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(patting_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -258,7 +258,7 @@ class Embeds(commands.Cog): try: # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Set member as the author member = ctx.message.author @@ -268,7 +268,7 @@ class Embeds(commands.Cog): # Set up the embed to display a random lemon gif embed = discord.Embed( title=f" | **{member.display_name}** Gives A Lemon To **{target.display_name}**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(lemon_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() diff --git a/cogs/FunCommands.py b/cogs/FunCommands.py index 036dc788..b07cd12e 100644 --- a/cogs/FunCommands.py +++ b/cogs/FunCommands.py @@ -5,11 +5,11 @@ import discord from discord.ext import commands from discord.ext.commands import BucketType, cooldown -import config +import Config from cogs.Embeds import error_function -# Grabbing the list of colours defined in the config.py file -colour_list = [c for c in config.colors.values()] +# Grabbing the list of colours defined in the Config.py file +colour_list = [c for c in Config.colors.values()] # Set up the cog diff --git a/cogs/WaifuImages.py b/cogs/WaifuImages.py index a4e9c619..bb57f91a 100644 --- a/cogs/WaifuImages.py +++ b/cogs/WaifuImages.py @@ -7,7 +7,7 @@ import discord from discord.ext import commands from discord.ext.commands import cooldown, BucketType -import config +import Config from cogs.Embeds import error_function @@ -26,14 +26,14 @@ class Waifus(commands.Cog): kakashi_array = file.readlines() # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Set member as the author member = ctx.message.author userAvatar = member.avatar_url embed = discord.Embed(title="**Hatake Kakashi**", - colour=discord.Colour(random.choice(config.colour_list))) + colour=discord.Colour(random.choice(Config.colour_list))) embed.set_image(url=random.choice(kakashi_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -61,14 +61,14 @@ class Waifus(commands.Cog): toga_array = file.readlines() # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Set member as the author member = ctx.message.author userAvatar = member.avatar_url embed = discord.Embed(title="**Himiko Toga**", - colour=discord.Colour(int(random.choice(config.colour_list)))) + colour=discord.Colour(int(random.choice(Config.colour_list)))) embed.set_image(url=random.choice(toga_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -95,13 +95,13 @@ class Waifus(commands.Cog): tamaki_array = file.readlines() # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # set member as the author member = ctx.message.author userAvatar = member.avatar_url - embed = discord.Embed(title="**Tamaki Suoh**", colour=discord.Colour(random.choice(config.colour_list))) + embed = discord.Embed(title="**Tamaki Suoh**", colour=discord.Colour(random.choice(Config.colour_list))) embed.set_image(url=random.choice(tamaki_array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -152,14 +152,14 @@ class Waifus(commands.Cog): array = file.readlines() # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Set member as the author member = ctx.message.author userAvatar = member.avatar_url embed = discord.Embed( title=f"Oh Look! A Cute Person ", - colour=discord.Colour(random.choice(config.colour_list))) + colour=discord.Colour(random.choice(Config.colour_list))) embed.set_image(url=random.choice(array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow() @@ -168,14 +168,14 @@ class Waifus(commands.Cog): def displayServerImage(array, ctx, name): # If the channel that the command has been sent is in the list of accepted channels - if str(ctx.channel) in config.channels: + if str(ctx.channel) in Config.channels: # Set member as the author member = ctx.message.author userAvatar = member.avatar_url embed = discord.Embed( title=f"**Oh Look! A Cute Picture of {name.capitalize()}!! **", - colour=discord.Colour(random.choice(config.colour_list))) + colour=discord.Colour(random.choice(Config.colour_list))) embed.set_image(url=random.choice(array)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.timestamp = datetime.datetime.utcnow()