mirror of https://github.com/sgoudham/Enso-Bot.git
You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
373 lines
14 KiB
Python
373 lines
14 KiB
Python
4 years ago
|
import datetime
|
||
5 years ago
|
import random
|
||
4 years ago
|
from contextlib import closing
|
||
5 years ago
|
|
||
4 years ago
|
from discord import Colour, Embed, Member
|
||
5 years ago
|
from discord.ext import commands
|
||
4 years ago
|
from discord.ext.commands import cooldown, command, BucketType
|
||
5 years ago
|
|
||
4 years ago
|
import db
|
||
4 years ago
|
from settings import colour_list
|
||
4 years ago
|
|
||
|
|
||
|
# Gets the member and user avatar
|
||
|
def getMember(ctx):
|
||
|
# Set member as the author
|
||
|
member = ctx.message.author
|
||
|
# Get the member avatar
|
||
|
userAvatar = member.avatar_url
|
||
|
|
||
|
return member, userAvatar
|
||
|
|
||
|
|
||
5 years ago
|
# Set up the Cog
|
||
4 years ago
|
class Interactive(commands.Cog):
|
||
|
"""Interactive Commands! (E.G Kiss/Hug/Cuddle)"""
|
||
|
|
||
5 years ago
|
def __init__(self, bot):
|
||
|
self.bot = bot
|
||
|
|
||
4 years ago
|
@command(name="kiss", aliases=["Kiss"])
|
||
4 years ago
|
@cooldown(1, 1, BucketType.user)
|
||
4 years ago
|
async def kiss(self, ctx, target: Member):
|
||
4 years ago
|
"""Kiss your partner"""
|
||
5 years ago
|
|
||
4 years ago
|
# Get the guild
|
||
|
guild = ctx.author.guild
|
||
|
|
||
4 years ago
|
# Use database connection
|
||
|
with db.connection() as conn:
|
||
|
|
||
|
# Get the author's row from the Members Table
|
||
4 years ago
|
select_query = """SELECT * FROM members WHERE discordID = (?) and guildID = (?)"""
|
||
|
val = ctx.author.id, guild.id,
|
||
4 years ago
|
with closing(conn.cursor()) as cursor:
|
||
4 years ago
|
|
||
4 years ago
|
# Execute the SQL Query
|
||
|
cursor.execute(select_query, val)
|
||
|
result = cursor.fetchone()
|
||
|
married_user = result[2]
|
||
4 years ago
|
|
||
|
# Error handling to make sure that the user can kiss themselves
|
||
|
if target.id == ctx.author.id:
|
||
4 years ago
|
kiss = False
|
||
4 years ago
|
title = f":kissing_heart: :kissing_heart: | **{ctx.author.name}** kissed **themselves**"
|
||
4 years ago
|
else:
|
||
4 years ago
|
kiss = True
|
||
4 years ago
|
title = f":kissing_heart: :kissing_heart: | **{ctx.author.name}** kissed **{target.display_name}**"
|
||
4 years ago
|
|
||
4 years ago
|
try:
|
||
4 years ago
|
# Make sure the user isn't trying to kiss someone else besides their partner
|
||
4 years ago
|
if married_user is None and kiss:
|
||
4 years ago
|
await ctx.send("Σ(‘◉⌓◉’) You need to be married in order to use this command! Baka!")
|
||
|
return
|
||
4 years ago
|
# Make sure that the married people can only kiss their partner
|
||
4 years ago
|
elif not str(target.id) == married_user and kiss:
|
||
4 years ago
|
await ctx.send("Σ(‘◉⌓◉’) You can only kiss your partner! Baka!")
|
||
|
return
|
||
|
except Exception as ex:
|
||
|
print(ex)
|
||
4 years ago
|
|
||
5 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
5 years ago
|
try:
|
||
|
|
||
4 years ago
|
# Open the file containing the kissing gifs
|
||
|
with open('images/FunCommands/kissing.txt') as file:
|
||
|
# Store content of the file in kissing_array
|
||
|
kissing_array = file.readlines()
|
||
5 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
5 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random kissing gif
|
||
|
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))
|
||
4 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
5 years ago
|
|
||
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
4 years ago
|
@command(name="cuddle", aliases=["Cuddle"])
|
||
4 years ago
|
@cooldown(1, 1, BucketType.user)
|
||
4 years ago
|
async def cuddle(self, ctx, target: Member):
|
||
4 years ago
|
"""Cuddle your partner"""
|
||
5 years ago
|
|
||
4 years ago
|
# Get the guild
|
||
|
guild = ctx.author.guild
|
||
|
|
||
4 years ago
|
# Use database connection
|
||
|
with db.connection() as conn:
|
||
|
|
||
|
# Get the author's row from the Members Table
|
||
4 years ago
|
select_query = """SELECT * FROM members WHERE discordID = (?) and guildID = (?)"""
|
||
|
val = ctx.author.id, guild.id
|
||
4 years ago
|
with closing(conn.cursor()) as cursor:
|
||
4 years ago
|
|
||
4 years ago
|
# Execute the SQL Query
|
||
|
cursor.execute(select_query, val)
|
||
|
result = cursor.fetchone()
|
||
|
married_user = result[2]
|
||
4 years ago
|
|
||
|
# Error handling to make sure that the user can cuddle themselves
|
||
|
if target.id == ctx.author.id:
|
||
|
cuddle = False
|
||
4 years ago
|
title = f":blush: :blush: | **{ctx.author.name}** cuddled **themselves**"
|
||
4 years ago
|
else:
|
||
|
cuddle = True
|
||
4 years ago
|
title = f":blush: :blush: | **{ctx.author.name}** cuddled **{target.display_name}**"
|
||
4 years ago
|
|
||
4 years ago
|
try:
|
||
4 years ago
|
# Make sure the user isn't trying to cuddle someone else besides their partner
|
||
4 years ago
|
if married_user is None and cuddle:
|
||
4 years ago
|
await ctx.send("Σ(‘◉⌓◉’) You need to be married in order to use this command! Baka!")
|
||
|
return
|
||
|
# Make sure that the married people can only cuddle their partner
|
||
4 years ago
|
elif not str(target.id) == married_user and cuddle:
|
||
4 years ago
|
await ctx.send("Σ(‘◉⌓◉’) You can only cuddle your partner! Baka!")
|
||
4 years ago
|
return
|
||
4 years ago
|
except Exception as ex:
|
||
|
print(ex)
|
||
4 years ago
|
|
||
5 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
|
try:
|
||
|
|
||
4 years ago
|
# Open the file containing the cuddling gifs
|
||
|
with open('images/FunCommands/cuddling.txt') as file:
|
||
|
# Store content of the file in cuddling_array
|
||
|
cuddling_array = file.readlines()
|
||
5 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
5 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random cuddling gif
|
||
|
embed = Embed(
|
||
|
title=title,
|
||
|
colour=Colour(int(random.choice(colour_list))),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
embed.set_image(url=random.choice(cuddling_array))
|
||
|
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
||
5 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
5 years ago
|
|
||
5 years ago
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
4 years ago
|
@command(name="kill", aliases=["Kill"])
|
||
|
@cooldown(1, 1, BucketType.user)
|
||
|
async def kill(self, ctx, target: Member):
|
||
4 years ago
|
"""Kill a person in the server"""
|
||
4 years ago
|
|
||
4 years ago
|
if target is ctx.author:
|
||
|
title = f":scream: :scream: | **{ctx.author.name}** killed **themselves**"
|
||
|
else:
|
||
4 years ago
|
title = f":scream: :scream: | **{ctx.author.name}** killed **{target.display_name}**"
|
||
4 years ago
|
|
||
4 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
|
try:
|
||
|
|
||
4 years ago
|
# Open the file containing the killing gifs
|
||
|
with open('images/FunCommands/killing.txt') as file:
|
||
|
# Store content of the file in killing_array
|
||
|
killing_array = file.readlines()
|
||
4 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
4 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random killing gif
|
||
|
embed = Embed(
|
||
|
title=title,
|
||
|
colour=Colour(int(random.choice(colour_list))),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
embed.set_image(url=random.choice(killing_array))
|
||
|
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
||
4 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
4 years ago
|
|
||
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
4 years ago
|
@command(name="slap", aliases=["Slap"])
|
||
4 years ago
|
@cooldown(1, 1, BucketType.user)
|
||
4 years ago
|
async def slap(self, ctx, target: Member):
|
||
4 years ago
|
"""Slap a person in the server"""
|
||
5 years ago
|
|
||
4 years ago
|
if target is ctx.author:
|
||
|
title = f":cold_sweat: :cold_sweat: | **{ctx.author.name}** slapped **themselves**"
|
||
|
else:
|
||
4 years ago
|
title = f":cold_sweat: :cold_sweat: | **{ctx.author.name}** slapped **{target.display_name}**"
|
||
4 years ago
|
|
||
5 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
5 years ago
|
try:
|
||
|
|
||
4 years ago
|
# Open the file containing the cuddling gifs
|
||
|
with open('images/FunCommands/slapping.txt') as file:
|
||
|
# Store content of the file in cuddling_array
|
||
|
slapping_array = file.readlines()
|
||
5 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
5 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random slapping gif
|
||
|
embed = Embed(
|
||
|
title=title,
|
||
|
colour=Colour(int(random.choice(colour_list))),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
embed.set_image(url=random.choice(slapping_array))
|
||
|
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
||
5 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
5 years ago
|
|
||
5 years ago
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
4 years ago
|
@command(name="pat", aliases=["Pat"])
|
||
4 years ago
|
@cooldown(1, 1, BucketType.user)
|
||
4 years ago
|
async def pat(self, ctx, target: Member):
|
||
4 years ago
|
"""Pat a person in the server"""
|
||
5 years ago
|
|
||
4 years ago
|
if target is ctx.author:
|
||
|
title = f":scream: :scream: | **{ctx.author.name}** patted **themselves**"
|
||
|
else:
|
||
4 years ago
|
title = f":scream: :scream: | **{ctx.author.name}** patted **{target.display_name}**"
|
||
4 years ago
|
|
||
5 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
5 years ago
|
try:
|
||
|
|
||
4 years ago
|
# Open the file containing the patting gifs
|
||
|
with open('images/FunCommands/patting.txt') as file:
|
||
|
# Store content of the file in patting_array
|
||
|
patting_array = file.readlines()
|
||
5 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
4 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random patting gif
|
||
|
embed = Embed(
|
||
|
title=title,
|
||
|
colour=Colour(int(random.choice(colour_list))),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
embed.set_image(url=random.choice(patting_array))
|
||
|
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
||
4 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
5 years ago
|
|
||
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
4 years ago
|
@command(name="lemon", aliases=["Lemon"])
|
||
4 years ago
|
@cooldown(1, 1, BucketType.user)
|
||
4 years ago
|
async def lemon(self, ctx, target: Member):
|
||
4 years ago
|
"""Give lemons to members in the user"""
|
||
5 years ago
|
|
||
4 years ago
|
if target is ctx.author:
|
||
|
title = f":relaxed: :relaxed: | **{ctx.author.name}** gave a lemon to **themselves**"
|
||
|
else:
|
||
4 years ago
|
title = f":relaxed: :relaxed: | **{ctx.author.name}** gave a lemon to **{target.display_name}**"
|
||
4 years ago
|
|
||
5 years ago
|
lemon_array = ["https://media.discordapp.net/attachments/669812887564320769/720093589056520202/lemon.gif",
|
||
|
"https://media.discordapp.net/attachments/669812887564320769/720093575492272208/lemon2.gif",
|
||
|
"https://media.discordapp.net/attachments/718484280925224981/719629805263257630/lemon.gif"]
|
||
5 years ago
|
|
||
|
# Surround with try/except to catch any exceptions that may occur
|
||
5 years ago
|
try:
|
||
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
5 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random lemon gif
|
||
|
embed = Embed(
|
||
|
title=title,
|
||
|
colour=Colour(int(random.choice(colour_list))),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
embed.set_image(url=random.choice(lemon_array))
|
||
|
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
||
5 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
4 years ago
|
|
||
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
|
@command(name="choke", aliases=["Choke"])
|
||
|
@cooldown(1, 1, BucketType.user)
|
||
|
async def choke(self, ctx, target: Member):
|
||
4 years ago
|
"""Choke a person in the server"""
|
||
4 years ago
|
|
||
4 years ago
|
if target is ctx.author:
|
||
|
title = f":confounded: :confounded: | **{ctx.author.name}** choked **themselves**"
|
||
|
else:
|
||
4 years ago
|
title = f":confounded: :confounded: | **{ctx.author.name}** choked **{target.display_name}**"
|
||
4 years ago
|
|
||
4 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
|
try:
|
||
4 years ago
|
# 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()
|
||
4 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
4 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random choking gif
|
||
|
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))
|
||
4 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
4 years ago
|
|
||
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
|
@command(name="hug", aliases=["Hug"])
|
||
|
@cooldown(1, 1, BucketType.user)
|
||
|
async def hug(self, ctx, target: Member):
|
||
4 years ago
|
"""Hug a person in the server"""
|
||
4 years ago
|
|
||
4 years ago
|
if target is ctx.author:
|
||
|
title = f":smiling_face_with_3_hearts: :smiling_face_with_3_hearts: | **{ctx.author.name}** hugged **themselves**"
|
||
|
else:
|
||
4 years ago
|
title = f":smiling_face_with_3_hearts: :smiling_face_with_3_hearts: | **{ctx.author.name}** hugged **{target.display_name}**"
|
||
4 years ago
|
|
||
4 years ago
|
# Surround with try/except to catch any exceptions that may occur
|
||
|
try:
|
||
|
|
||
4 years ago
|
# Open the file containing the hug gifs
|
||
|
with open('images/FunCommands/hugging.txt') as file:
|
||
|
# Store content of the file in hugging_array
|
||
|
hugging_array = file.readlines()
|
||
4 years ago
|
|
||
4 years ago
|
# Get the member and the userAvatar
|
||
|
member, userAvatar = getMember(ctx)
|
||
4 years ago
|
|
||
4 years ago
|
# Set up the embed to display a random hugging gif
|
||
|
embed = Embed(
|
||
|
title=title,
|
||
|
colour=Colour(int(random.choice(colour_list))),
|
||
|
timestamp=datetime.datetime.utcnow())
|
||
|
embed.set_image(url=random.choice(hugging_array))
|
||
|
embed.set_footer(text=f"Requested by {member}", icon_url='{}'.format(userAvatar))
|
||
4 years ago
|
|
||
4 years ago
|
# Send the embedded message to the user
|
||
|
await ctx.send(embed=embed)
|
||
5 years ago
|
|
||
|
except FileNotFoundError as e:
|
||
|
print(e)
|
||
|
|
||
5 years ago
|
|
||
5 years ago
|
def setup(bot):
|
||
4 years ago
|
bot.add_cog(Interactive(bot))
|