Getting rid of the channel restrictions

pull/8/head
sgoudham 4 years ago
parent be56793944
commit 8633e9ecdb

@ -6,7 +6,6 @@ from discord import Embed, Colour
from discord.ext import commands from discord.ext import commands
from discord.ext.commands import cooldown, BucketType, command from discord.ext.commands import cooldown, BucketType, command
import settings
from settings import colour_list from settings import colour_list
# Defining the full names of the waifu's/husbando's # Defining the full names of the waifu's/husbando's
@ -114,49 +113,46 @@ class Waifus_Husbandos(commands.Cog):
# Defining array for the list of waifus available # Defining array for the list of waifus available
waifu_array = ["toga", "yumeko", "maki"] waifu_array = ["toga", "yumeko", "maki"]
# If the channel that the command has been sent is in the list of accepted channels # if a name is specified
if str(ctx.channel) in settings.channels: if waifu:
# Get the lowercase
proper_waifu = waifu.lower()
# if a name is specified # if the user does ~w list
if waifu: if proper_waifu == "list":
# Get the lowercase # Tell the user to try the waifus in the array
proper_waifu = waifu.lower() await ctx.send(f"Try the waifu's listed below!")
# if the user does ~w list # Send the list of waifus in the bot to the channel
if proper_waifu == "list": waifu_list = string.capwords(', '.join(map(str, waifu_array)))
# Tell the user to try the waifus in the array await ctx.send(waifu_list)
await ctx.send(f"Try the waifu's listed below!")
# Send the list of waifus in the bot to the channel else:
waifu_list = string.capwords(', '.join(map(str, waifu_array))) # Surround with try/except to catch any exceptions that may occur
await ctx.send(waifu_list) try:
else:
# Surround with try/except to catch any exceptions that may occur
try:
# Retrieve image of the waifu specified # Retrieve image of the waifu specified
with open(f'images/AnimeImages/Waifus/{proper_waifu}.txt') as file: with open(f'images/AnimeImages/Waifus/{proper_waifu}.txt') as file:
w_array = file.readlines() w_array = file.readlines()
# Get the full name of the waifu # Get the full name of the waifu
full_name = Abbrev(proper_waifu) full_name = Abbrev(proper_waifu)
# Embed the image into a message and send it to the channel # Embed the image into a message and send it to the channel
embed = displayAnimeImage(w_array, ctx, full_name) embed = displayAnimeImage(w_array, ctx, full_name)
await ctx.send(embed=embed) await ctx.send(embed=embed)
except Exception as e: except Exception as e:
print(e) print(e)
# Send error message saying that the person isn't recognised # Send error message saying that the person isn't recognised
await ctx.send(f"Sorry! That waifu doesn't exist!" await ctx.send(f"Sorry! That waifu doesn't exist!"
f"\nPlease do **~w list** to see the list of waifu's") f"\nPlease do **~w list** to see the list of waifu's")
else: else:
# Get embed from randomWaifu() and send it to the channel # Get embed from randomWaifu() and send it to the channel
embed = randomWaifu(ctx, waifu_array) embed = randomWaifu(ctx, waifu_array)
await ctx.send(embed=embed) await ctx.send(embed=embed)
# Bot ~h/husbando command for the husbando's stored in the bot # Bot ~h/husbando command for the husbando's stored in the bot
@command(name="h", aliases=['H']) @command(name="h", aliases=['H'])
@ -166,50 +162,47 @@ class Waifus_Husbandos(commands.Cog):
# Defining array for the list of husbando's available # Defining array for the list of husbando's available
husbando_array = ["husk", "kakashi", "tamaki"] husbando_array = ["husk", "kakashi", "tamaki"]
# If the channel that the command has been sent is in the list of accepted channels # if a name is specified
if str(ctx.channel) in settings.channels: if husbando:
# Get the lowercase
proper_husbando = husbando.lower()
# if a name is specified # Surround with try/except to catch any exceptions that may occur
if husbando: try:
# Get the lowercase
proper_husbando = husbando.lower()
# Surround with try/except to catch any exceptions that may occur # if the user does ~h list
try: if proper_husbando == "list":
# Tell the user to try the husbando's in the array
await ctx.send(f"Try the husbando's listed below!")
# if the user does ~h list # Send the list of waifus in the bot to the channel
if proper_husbando == "list": husbando_list = string.capwords(', '.join(map(str, husbando_array)))
# Tell the user to try the husbando's in the array await ctx.send(husbando_list)
await ctx.send(f"Try the husbando's listed below!")
# Send the list of waifus in the bot to the channel else:
husbando_list = string.capwords(', '.join(map(str, husbando_array))) # Retrieve image of the husbando specified
await ctx.send(husbando_list) with open(f'images/AnimeImages/Husbandos/{proper_husbando}.txt') as file:
h_array = file.readlines()
else: # Get the full name of the husbando
# Retrieve image of the husbando specified full_name = Abbrev(proper_husbando)
with open(f'images/AnimeImages/Husbandos/{proper_husbando}.txt') as file:
h_array = file.readlines()
# Get the full name of the husbando # Embed the image into a message and send it to the channel
full_name = Abbrev(proper_husbando) embed = displayAnimeImage(h_array, ctx, full_name)
await ctx.send(embed=embed)
# Embed the image into a message and send it to the channel except Exception as e:
embed = displayAnimeImage(h_array, ctx, full_name) print(e)
await ctx.send(embed=embed)
except Exception as e: # Send error message saying that the person isn't recognised
print(e) await ctx.send(
f"Sorry! That husbando doesn't exist!"
# Send error message saying that the person isn't recognised f"\nPlease do **~h list** to see the list of husbando's")
await ctx.send( else:
f"Sorry! That husbando doesn't exist!"
f"\nPlease do **~h list** to see the list of husbando's")
else:
# Get embed from randomHusbando() and send it to the channel # Get embed from randomHusbando() and send it to the channel
embed = randomHusbando(ctx, husbando_array) embed = randomHusbando(ctx, husbando_array)
await ctx.send(embed=embed) await ctx.send(embed=embed)
def setup(bot): def setup(bot):

Loading…
Cancel
Save