Getting rid of Enso specific channel restrictions

Rest well my prince
pull/8/head
sgoudham 4 years ago
parent d368173c31
commit 3b21b0b0f5

@ -1,4 +1,3 @@
import asyncio
import datetime import datetime
import random import random
@ -7,7 +6,6 @@ from discord.ext import commands
from discord.ext.commands import cooldown, command, BucketType from discord.ext.commands import cooldown, command, BucketType
import db import db
import settings
from settings import colour_list, enso_ensochancommands_Mention from settings import colour_list, enso_ensochancommands_Mention
@ -74,37 +72,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Open the file containing the kissing gifs
if str(ctx.channel) in settings.channels: with open('images/FunCommands/kissing.txt') as file:
# Store content of the file in kissing_array
kissing_array = file.readlines()
# Open the file containing the kissing gifs # Get the member and the userAvatar
with open('images/FunCommands/kissing.txt') as file: member, userAvatar = getMember(ctx)
# Store content of the file in kissing_array
kissing_array = file.readlines()
# Get the member and the userAvatar # Set up the embed to display a random kissing gif
member, userAvatar = getMember(ctx) embed = Embed(
title=title,
colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow())
embed.set_image(url=random.choice(kissing_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
# Set up the embed to display a random kissing gif # Send the embedded message to the user
embed = Embed( await ctx.send(embed=embed)
title=title,
colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow())
embed.set_image(url=random.choice(kissing_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
# Send the embedded message to the user
await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -152,37 +137,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Open the file containing the cuddling gifs
if str(ctx.channel) in settings.channels: with open('images/FunCommands/cuddling.txt') as file:
# Store content of the file in cuddling_array
# Open the file containing the cuddling gifs cuddling_array = file.readlines()
with open('images/FunCommands/cuddling.txt') as file:
# Store content of the file in cuddling_array
cuddling_array = file.readlines()
# Get the member and the userAvatar # Get the member and the userAvatar
member, userAvatar = getMember(ctx) member, userAvatar = getMember(ctx)
# Set up the embed to display a random cuddling gif # Set up the embed to display a random cuddling gif
embed = Embed( embed = Embed(
title=title, title=title,
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow()) timestamp=datetime.datetime.utcnow())
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))
# Send the embedded message to the user # Send the embedded message to the user
await ctx.send(embed=embed) await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -200,37 +172,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Open the file containing the killing gifs
if str(ctx.channel) in settings.channels: with open('images/FunCommands/killing.txt') as file:
# Store content of the file in killing_array
# Open the file containing the killing gifs killing_array = file.readlines()
with open('images/FunCommands/killing.txt') as file:
# Store content of the file in killing_array
killing_array = file.readlines()
# Get the member and the userAvatar # Get the member and the userAvatar
member, userAvatar = getMember(ctx) member, userAvatar = getMember(ctx)
# Set up the embed to display a random killing gif # Set up the embed to display a random killing gif
embed = Embed( embed = Embed(
title=title, title=title,
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow()) timestamp=datetime.datetime.utcnow())
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))
# Send the embedded message to the user # Send the embedded message to the user
await ctx.send(embed=embed) await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -248,37 +207,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Open the file containing the cuddling gifs
if str(ctx.channel) in settings.channels: with open('images/FunCommands/slapping.txt') as file:
# Store content of the file in cuddling_array
# Open the file containing the cuddling gifs slapping_array = file.readlines()
with open('images/FunCommands/slapping.txt') as file:
# Store content of the file in cuddling_array
slapping_array = file.readlines()
# Get the member and the userAvatar # Get the member and the userAvatar
member, userAvatar = getMember(ctx) member, userAvatar = getMember(ctx)
# Set up the embed to display a random slapping gif # Set up the embed to display a random slapping gif
embed = Embed( embed = Embed(
title=title, title=title,
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow()) timestamp=datetime.datetime.utcnow())
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))
# Send the embedded message to the user # Send the embedded message to the user
await ctx.send(embed=embed) await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -296,37 +242,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Open the file containing the patting gifs
if str(ctx.channel) in settings.channels: with open('images/FunCommands/patting.txt') as file:
# Store content of the file in patting_array
# Open the file containing the patting gifs patting_array = file.readlines()
with open('images/FunCommands/patting.txt') as file:
# Store content of the file in patting_array
patting_array = file.readlines()
# Get the member and the userAvatar # Get the member and the userAvatar
member, userAvatar = getMember(ctx) member, userAvatar = getMember(ctx)
# Set up the embed to display a random patting gif # Set up the embed to display a random patting gif
embed = Embed( embed = Embed(
title=title, title=title,
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow()) timestamp=datetime.datetime.utcnow())
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))
# Send the embedded message to the user # Send the embedded message to the user
await ctx.send(embed=embed) await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -348,32 +281,19 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Get the member and the userAvatar
if str(ctx.channel) in settings.channels: member, userAvatar = getMember(ctx)
# Get the member and the userAvatar
member, userAvatar = getMember(ctx)
# Set up the embed to display a random lemon gif # Set up the embed to display a random lemon gif
embed = Embed( embed = Embed(
title=title, title=title,
colour=Colour(int(random.choice(colour_list))), colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow()) timestamp=datetime.datetime.utcnow())
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))
# Send the embedded message to the user # Send the embedded message to the user
await ctx.send(embed=embed) await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -390,38 +310,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# Open the file containing the choking gifs
with open('images/FunCommands/choking.txt') as file:
# Store content of the file in choking_array
choking_array = file.readlines()
# If the channel that the command has been sent is in the list of accepted channels # Get the member and the userAvatar
if str(ctx.channel) in settings.channels: member, userAvatar = getMember(ctx)
# Open the file containing the choking gifs
with open('images/FunCommands/choking.txt') as file:
# Store content of the file in choking_array
choking_array = file.readlines()
# Get the member and the userAvatar # Set up the embed to display a random choking gif
member, userAvatar = getMember(ctx) embed = Embed(
title=title,
colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow())
embed.set_image(url=random.choice(choking_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
# Set up the embed to display a random choking gif # Send the embedded message to the user
embed = Embed( await ctx.send(embed=embed)
title=title,
colour=Colour(int(random.choice(colour_list))),
timestamp=datetime.datetime.utcnow())
embed.set_image(url=random.choice(choking_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
# Send the embedded message to the user
await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds
await asyncio.sleep(2.5)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)
@ -439,37 +345,24 @@ class interactive(commands.Cog):
# Surround with try/except to catch any exceptions that may occur # Surround with try/except to catch any exceptions that may occur
try: try:
# If the channel that the command has been sent is in the list of accepted channels # Open the file containing the hug gifs
if str(ctx.channel) in settings.channels: with open('images/FunCommands/hugging.txt') as file:
# Store content of the file in hugging_array
hugging_array = file.readlines()
# Open the file containing the hug gifs # Get the member and the userAvatar
with open('images/FunCommands/hugging.txt') as file: member, userAvatar = getMember(ctx)
# Store content of the file in hugging_array
hugging_array = file.readlines()
# Get the member and the userAvatar # Set up the embed to display a random hugging gif
member, userAvatar = getMember(ctx) embed = Embed(
title=title,
# Set up the embed to display a random hugging gif colour=Colour(int(random.choice(colour_list))),
embed = Embed( timestamp=datetime.datetime.utcnow())
title=title, embed.set_image(url=random.choice(hugging_array))
colour=Colour(int(random.choice(colour_list))), embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
timestamp=datetime.datetime.utcnow())
embed.set_image(url=random.choice(hugging_array))
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
# Send the embedded message to the user
await ctx.send(embed=embed)
# else the command is sent in an invalid channel
else:
# Call error_function() and display it to the user
message = await ctx.send(error_function())
# Let the user read the message for 2.5 seconds # Send the embedded message to the user
await asyncio.sleep(2.5) await ctx.send(embed=embed)
# Delete the message
await message.delete()
except FileNotFoundError as e: except FileNotFoundError as e:
print(e) print(e)

Loading…
Cancel
Save