Refactored code to make sure 2 config files didn't get messed up

pull/2/head
sgoudham 5 years ago
parent 0c0f572696
commit f4edb78591

@ -6,7 +6,7 @@ import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import BucketType, cooldown from discord.ext.commands import BucketType, cooldown
import config import Config
# Set up the Cog # Set up the Cog
@ -24,7 +24,7 @@ class Embeds(commands.Cog):
try: try:
# If the channel that the command has been sent is in the list of accepted channels # 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 # Open the file containing the kissing gifs
with open('images/FunCommands/kissing.txt') as file: 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 # Set up the embed to display a random kissing gif
embed = discord.Embed( embed = discord.Embed(
title=f"<a:huh:676195228872474643> <a:huh:676195228872474643> | **{member.display_name}** kissed **{target.display_name}**", title=f"<a:huh:676195228872474643> <a:huh:676195228872474643> | **{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_image(url=random.choice(kissing_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -70,7 +70,7 @@ class Embeds(commands.Cog):
try: try:
# If the channel that the command has been sent is in the list of accepted channels # 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 # Open the file containing the killing gifs
with open('images/FunCommands/killing.txt') as file: 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 # Set up the embed to display a random killing gif
embed = discord.Embed( embed = discord.Embed(
title=f"<:monkaW:718960264896184380> <:monkaW:718960264896184380> | **{member.display_name}** killed **{target.display_name}**", 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_image(url=random.choice(killing_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -116,7 +116,7 @@ class Embeds(commands.Cog):
try: try:
# If the channel that the command has been sent is in the list of accepted channels # 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 # Open the file containing the cuddling gifs
with open('images/FunCommands/cuddling.txt') as file: 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 # Set up the embed to display a random cuddling gif
embed = discord.Embed( embed = discord.Embed(
title=f"<:blushlook1:677310734123663363> <:blushlook2:679524467248201769> | **{member.display_name}** cuddled **{target.display_name}**", 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_image(url=random.choice(cuddling_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -162,7 +162,7 @@ class Embeds(commands.Cog):
try: try:
# If the channel that the command has been sent is in the list of accepted channels # 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 # Open the file containing the cuddling gifs
with open('images/FunCommands/slapping.txt') as file: 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 # Set up the embed to display a random slapping gif
embed = discord.Embed( embed = discord.Embed(
title=f"<:baka:718942872061083678> <:baka:718942872061083678> | **{member.display_name}** slapped **{target.display_name}**", 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_image(url=random.choice(slapping_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -208,7 +208,7 @@ class Embeds(commands.Cog):
try: try:
# If the channel that the command has been sent is in the list of accepted channels # 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 # Open the file containing the patting gifs
with open('images/FunCommands/patting.txt') as file: 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 # Set up the embed to display a random patting gif
embed = discord.Embed( embed = discord.Embed(
title=f":pleading_face: :pleading_face: | **{member.display_name}** patted **{target.display_name}**", 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_image(url=random.choice(patting_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -258,7 +258,7 @@ class Embeds(commands.Cog):
try: try:
# If the channel that the command has been sent is in the list of accepted channels # 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 # Set member as the author
member = ctx.message.author member = ctx.message.author
@ -268,7 +268,7 @@ class Embeds(commands.Cog):
# Set up the embed to display a random lemon gif # Set up the embed to display a random lemon gif
embed = discord.Embed( embed = discord.Embed(
title=f"<a:huh:676195228872474643> <a:huh:676195228872474643> | **{member.display_name}** Gives A Lemon To **{target.display_name}**", title=f"<a:huh:676195228872474643> <a:huh:676195228872474643> | **{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_image(url=random.choice(lemon_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()

@ -5,11 +5,11 @@ import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import BucketType, cooldown from discord.ext.commands import BucketType, cooldown
import config import Config
from cogs.Embeds import error_function from cogs.Embeds import error_function
# Grabbing the list of colours defined in the config.py file # Grabbing the list of colours defined in the Config.py file
colour_list = [c for c in config.colors.values()] colour_list = [c for c in Config.colors.values()]
# Set up the cog # Set up the cog

@ -7,7 +7,7 @@ import discord
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import cooldown, BucketType from discord.ext.commands import cooldown, BucketType
import config import Config
from cogs.Embeds import error_function from cogs.Embeds import error_function
@ -26,14 +26,14 @@ class Waifus(commands.Cog):
kakashi_array = file.readlines() kakashi_array = file.readlines()
# If the channel that the command has been sent is in the list of accepted channels # 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 # Set member as the author
member = ctx.message.author member = ctx.message.author
userAvatar = member.avatar_url userAvatar = member.avatar_url
embed = discord.Embed(title="**Hatake Kakashi**", 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_image(url=random.choice(kakashi_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -61,14 +61,14 @@ class Waifus(commands.Cog):
toga_array = file.readlines() toga_array = file.readlines()
# If the channel that the command has been sent is in the list of accepted channels # 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 # Set member as the author
member = ctx.message.author member = ctx.message.author
userAvatar = member.avatar_url userAvatar = member.avatar_url
embed = discord.Embed(title="**Himiko Toga**", 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_image(url=random.choice(toga_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -95,13 +95,13 @@ class Waifus(commands.Cog):
tamaki_array = file.readlines() tamaki_array = file.readlines()
# If the channel that the command has been sent is in the list of accepted channels # 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 # set member as the author
member = ctx.message.author member = ctx.message.author
userAvatar = member.avatar_url 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_image(url=random.choice(tamaki_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -152,14 +152,14 @@ class Waifus(commands.Cog):
array = file.readlines() array = file.readlines()
# If the channel that the command has been sent is in the list of accepted channels # 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 # Set member as the author
member = ctx.message.author member = ctx.message.author
userAvatar = member.avatar_url userAvatar = member.avatar_url
embed = discord.Embed( embed = discord.Embed(
title=f"Oh Look! A Cute Person <a:huh:676195228872474643> <a:huh:676195228872474643> ", title=f"Oh Look! A Cute Person <a:huh:676195228872474643> <a:huh:676195228872474643> ",
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_image(url=random.choice(array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()
@ -168,14 +168,14 @@ class Waifus(commands.Cog):
def displayServerImage(array, ctx, name): def displayServerImage(array, ctx, name):
# If the channel that the command has been sent is in the list of accepted channels # 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 # Set member as the author
member = ctx.message.author member = ctx.message.author
userAvatar = member.avatar_url userAvatar = member.avatar_url
embed = discord.Embed( embed = discord.Embed(
title=f"**Oh Look! A Cute Picture of {name.capitalize()}!! <a:huh:676195228872474643> <a:huh:676195228872474643> **", title=f"**Oh Look! A Cute Picture of {name.capitalize()}!! <a:huh:676195228872474643> <a:huh:676195228872474643> **",
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_image(url=random.choice(array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar)) embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
embed.timestamp = datetime.datetime.utcnow() embed.timestamp = datetime.datetime.utcnow()

Loading…
Cancel
Save