1
Fork 0
mirror of https://github.com/wlinator/luminara.git synced 2024-10-02 18:23:12 +00:00

HUGE UPDATE

This commit is contained in:
wlinator 2024-03-18 18:48:12 +01:00
parent 1d9ed6e0a4
commit cf21878d6e
14 changed files with 516 additions and 551 deletions

View file

@ -56,6 +56,15 @@ class GenericErrors:
return embed
@staticmethod
def private_message_only(ctx):
embed = clean_error_embed(ctx)
embed.description += f"this command can only be used in private messages."
embed.set_footer(text=f"For more info do '{formatter.get_prefix(ctx)}help {formatter.get_invoked_name(ctx)}'",
icon_url=question_icon)
return embed
class EconErrors:
@staticmethod

13
main.py
View file

@ -132,8 +132,7 @@ async def on_command_error(ctx, error) -> None:
elif isinstance(error, (discord.CheckFailure, commands.CheckFailure)):
logs.info(f"[CommandHandler] {ctx.author.name} check failure: \"/{ctx.command.qualified_name}\"")
elif isinstance(error, (commands.MissingRequiredArgument, commands.BadArgument)):
# handle locally in module's __init__.py
elif isinstance(error, (commands.MissingRequiredArgument, commands.BadArgument, commands.CommandNotFound)):
pass
else:
@ -156,15 +155,11 @@ reactions = json_loader.load_reactions()
def load_modules():
modules_list = [
"admin",
"birthdays",
"economy",
"misc"
]
module_list = [d for d in os.listdir("modules") if os.path.isdir(os.path.join("modules", d))]
loaded_modules = set()
for module in modules_list:
for module in module_list:
if module in loaded_modules:
continue # module is already loaded

View file

@ -1,16 +1,8 @@
import logging
import discord
from discord.ext import commands, bridge
import datetime, time
from lib.embeds.info import MiscInfo
from modules.admin import award
from modules.admin import award, sql
from lib.embeds.error import EconErrors
from lib import checks
from main import strings
logs = logging.getLogger('Racu.Core')
class Admin(commands.Cog):
@ -41,9 +33,25 @@ class Admin(commands.Cog):
elif isinstance(error, commands.BadArgument):
await ctx.respond(embed=EconErrors.bad_bet_argument(ctx))
@bridge.bridge_command(
name="sqlselect",
aliases=["sqls"],
description="Perform a SELECT query in the database.",
help="Perform a SELECT query in the database. This can only be done by the owner of Racu."
)
@commands.check(checks.bot_owner)
async def select(self, ctx, *, query: str):
return await sql.select_cmd(ctx, query)
@bridge.bridge_command(
name="sqlinject",
aliases=["sqli"],
description="Change a value in the database. (DANGEROUS)",
help="Change a value in the database. This can only be done by the owner of Racu. (DANGEROUS)"
)
@commands.check(checks.bot_owner)
async def inject(self, ctx, *, query: str):
return await sql.inject_cmd(ctx, query)
def setup(client):

22
modules/admin/sql.py Normal file
View file

@ -0,0 +1,22 @@
import sqlite3
from db import database
async def select_cmd(ctx, query: str):
if query.lower().startswith("select "):
query = query[7:]
try:
results = database.select_query(f"SELECT {query}")
except sqlite3.Error as error:
results = error
return await ctx.respond(content=f"```SELECT {query}```\n```{results}```", ephemeral=True)
async def inject_cmd(ctx, query: str):
try:
database.execute_query(query)
await ctx.respond(content=f"That worked!\n```{query}```", ephemeral=True)
except sqlite3.Error as error:
await ctx.respond(content=f"Query:\n```{query}```\nError message:\n```{error}```", ephemeral=True)

View file

@ -1,14 +1,9 @@
import logging
import discord
from discord.ext import commands, bridge
from lib import checks
from lib.embeds.error import EconErrors
from lib.embeds.error import GenericErrors
from modules.economy import leaderboard, blackjack, sell, slots, balance, stats, give, inventory, daily
logs = logging.getLogger('Racu.Core')
from lib.embeds.error import EconErrors, GenericErrors
from modules.economy import blackjack, sell, slots, balance, stats, give, inventory, daily
class Economy(commands.Cog):
@ -120,18 +115,6 @@ class Economy(commands.Cog):
async def inventory(self, ctx):
return await inventory.cmd(self, ctx)
@bridge.bridge_command(
name="leaderboard",
aliases=["lb", "xplb"],
description="Are ya winning' son?",
help="Shows the guild's level leaderboard by default. You can switch to currency and /daily leaderboard.",
guild_only=True
)
@commands.check(checks.channel)
@commands.cooldown(1, 180, commands.BucketType.user)
async def leaderboard_command(self, ctx):
return await leaderboard.cmd(ctx)
@bridge.bridge_command(
name="sell",
description="Sell items from your inventory.",

View file

@ -1,414 +0,0 @@
import asyncio
import logging
import os
import subprocess
import discord
from discord.ext import commands
from lib import interaction, embeds_old, checks
logs = logging.getLogger('Racu.Core')
class BasicCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.slash_command(
name="intro",
guild_only=False,
description="This command can only be done in DMs."
)
@commands.dm_only()
async def intro(self, ctx):
# rewrite this whole command
guild_id = 719227135151046699
channel_id = 973619250507972618
muted_role_id = 754895743151505489
nickname = None
age = None
location = None
pronouns = None
likes = None
dislikes = None
languages = None
sexuality = None
relationship_status = None
extra = None
guild = self.client.get_guild(guild_id)
member = await guild.fetch_member(ctx.author.id)
if member and discord.utils.get(member.roles, id=muted_role_id):
em = discord.Embed(description="You're muted in the Rave Cave. You can't perform this command.",
color=0xadcca6)
await ctx.respond(embed=em)
logs.warning(f"{ctx.author.name} couldn't do the intro command: Muted in the Race Cave")
return
# elif member and not discord.lib.get(member.roles, id=719995790319157279):
# em = discord.Embed(description="It seems that you don't have permission to do that!")
# await ctx.respond(embed=em)
# logs.warning(f"{ctx.author.name} couldn't do the intro command: No Permissions")
# return
embed = discord.Embed(color=0xadcca6,
title=f"Hey {ctx.author.name}!",
description=f"This command will serve as a questionnaire "
f"for your entry to <#{channel_id}>. Please keep your answers \"PG-13.\"")
embed.add_field(name="Short intro", value="Click the blue button to use the short form, this one has "
"__6 questions__, which is filled out promptly & contains the "
"most important elements needed to briefly describe you.")
embed.add_field(name="Extended intro", value="Click the green button to fill out an extended form with "
"__10 questions__ (including an \"extras\" field where you "
"can unleash your creativity), this one takes a bit longer "
"to fill out but gives a more detailed portrayal of you.")
embed.set_footer(text="Please don't abuse this command.")
embed.set_thumbnail(url="https://cdn.discordapp.com/icons/719227135151046699/49df8c284382af9dbcfd629c8eadc52c"
".webp?size=96")
view = interaction.IntroButtons(ctx)
await ctx.respond(embed=embed, view=view)
await view.wait()
def check(message):
return message.author == ctx.author and isinstance(message.channel, discord.DMChannel)
if view.clickedShort:
logs.debug(f"{ctx.author.name} clicked Short Intro")
# START NICKNAME
await ctx.send(embed=embeds_old.simple_question_first("How would you like to be identified in the server?"))
try:
nickname_message = await self.client.wait_for('message', check=check, timeout=120)
nickname = nickname_message.content
if len(nickname) > 100:
nickname = nickname[:100]
nickname = nickname.replace("\n", " ")
logs.debug(f"{ctx.author.name} nickname: {nickname}")
# START AGE
await ctx.send(embed=embeds_old.simple_question_5("How old are you?"),
content=f"Recorded answer: {nickname}")
try:
age_message = await self.client.wait_for('message', check=check, timeout=120)
age = age_message.content
if len(age) > 5:
age = age[:5]
age = age.replace("\n", " ")
logs.debug(f"{ctx.author.name} age: {age}")
# START LOCATION
view = interaction.LocationOptions(ctx)
await ctx.send(embed=embeds_old.simple_question_none("Where do you live?"),
view=view,
content=f"Recorded answer: {age}")
await view.wait()
location = view.location
if not view.location:
await ctx.send(embed=embeds_old.no_time())
return
logs.debug(f"{ctx.author.name} location: {location}")
# START PRONOUNS
await ctx.send(
embed=embeds_old.simple_question_30("What are your preferred pronouns?"),
content=f"Recorded answer: {location}")
try:
pronouns_message = await self.client.wait_for('message', check=check, timeout=120)
pronouns = pronouns_message.content
if len(pronouns) > 30:
pronouns = pronouns[:30]
pronouns = pronouns.replace("\n", " ")
logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
# START LIKES
await ctx.send(embed=embeds_old.simple_question_300("Likes & interests"),
content=f"Recorded answer: {pronouns}")
try:
likes_message = await self.client.wait_for('message', check=check, timeout=300)
likes = likes_message.content
if len(likes) > 300:
likes = likes[:300]
likes = likes.replace("\n", " ")
logs.debug(f"{ctx.author.name} likes: {likes}")
# START DISLIKES
await ctx.send(embed=embeds_old.simple_question_300("Dislikes"),
content=f"Recorded answer: {likes}")
try:
dislikes_message = await self.client.wait_for('message', check=check, timeout=300)
dislikes = dislikes_message.content
if len(dislikes) > 300:
dislikes = dislikes[:300]
dislikes = dislikes.replace("\n", " ")
logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
# POST EXAMPLE EMBED AND FINAL IF APPROVED
em = embeds_old.final_embed_short(ctx, nickname, age, location, pronouns, likes, dislikes)
view = interaction.Confirm(ctx)
await ctx.send(embed=em, content=f"Introduction of <@{ctx.author.id}>", view=view)
await view.wait()
if view.clickedConfirm:
intro_channel = guild.get_channel(channel_id)
await intro_channel.send(embed=em, content=f"Introduction of <@{ctx.author.id}>")
await ctx.send(embed=embeds_old.final_confirmation(channel_id))
logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
return
else:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
elif view.clickedLong:
logs.debug(f"{ctx.author.name} clicked Long Intro")
# START NICKNAME
await ctx.send(embed=embeds_old.simple_question_first_extended(
"How would you like to be identified in the server?"))
try:
nickname_message = await self.client.wait_for('message', check=check, timeout=120)
nickname = nickname_message.content
if len(nickname) > 100:
nickname = nickname[:100]
nickname = nickname.replace("\n", " ")
logs.debug(f"{ctx.author.name} nickname: {nickname}")
# START AGE
await ctx.send(embed=embeds_old.simple_question_5("How old are you?"),
content=f"Recorded answer: {nickname}")
try:
age_message = await self.client.wait_for('message', check=check, timeout=120)
age = age_message.content
if len(age) > 5:
age = age[:5]
age = age.replace("\n", " ")
logs.debug(f"{ctx.author.name} age: {age}")
# START LOCATION
view = interaction.LocationOptions(ctx)
await ctx.send(embed=embeds_old.simple_question_none("Where do you live?"),
view=view,
content=f"Recorded answer: {age}")
await view.wait()
location = view.location
if not view.location:
await ctx.send(embed=embeds_old.no_time())
return
logs.debug(f"{ctx.author.name} location: {location}")
# START LANGUAGES
await ctx.send(
embed=embeds_old.simple_question_100("Which languages do you speak?"),
content=f"Recorded answer: {location}"
)
try:
languages_message = await self.client.wait_for('message', check=check, timeout=200)
languages = languages_message.content
if len(languages) > 30:
languages = languages[:30]
languages = languages.replace("\n", " ")
logs.debug(f"{ctx.author.name} languages: {languages}")
# START PRONOUNS
await ctx.send(
embed=embeds_old.simple_question_30("What are your preferred pronouns?"),
content=f"Recorded answer: {languages}")
try:
pronouns_message = await self.client.wait_for('message', check=check, timeout=120)
pronouns = pronouns_message.content
if len(pronouns) > 30:
pronouns = pronouns[:30]
pronouns = pronouns.replace("\n", " ")
logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
# START SEXUALITY
await ctx.send(
embed=embeds_old.simple_question_30("What's your sexuality?"),
content=f"Recorded answer: {pronouns}")
try:
sexuality_message = await self.client.wait_for('message', check=check, timeout=120)
sexuality = sexuality_message.content
if len(sexuality) > 30:
sexuality = sexuality[:30]
sexuality = sexuality.replace("\n", " ")
logs.debug(f"{ctx.author.name} sexuality: {sexuality}")
# START RELATIONSHIP_STATUS
await ctx.send(
embed=embeds_old.simple_question_30("What's your current relationship status?"),
content=f"Recorded answer: {sexuality}")
try:
relationship_status_message = await self.client.wait_for('message', check=check,
timeout=120)
relationship_status = relationship_status_message.content
if len(relationship_status) > 30:
relationship_status = relationship_status[:30]
relationship_status = relationship_status.replace("\n", " ")
logs.debug(f"{ctx.author.name} relationship_status: {relationship_status}")
# START LIKES
await ctx.send(embed=embeds_old.simple_question_300("Likes & interests"),
content=f"Recorded answer: {relationship_status}")
try:
likes_message = await self.client.wait_for('message', check=check, timeout=300)
likes = likes_message.content
if len(likes) > 300:
likes = likes[:300]
likes = likes.replace("\n", " ")
logs.debug(f"{ctx.author.name} likes: {likes}")
# START DISLIKES
await ctx.send(embed=embeds_old.simple_question_300("Dislikes"),
content=f"Recorded answer: {likes}")
try:
dislikes_message = await self.client.wait_for('message', check=check,
timeout=300)
dislikes = dislikes_message.content
if len(dislikes) > 300:
dislikes = dislikes[:300]
dislikes = dislikes.replace("\n", " ")
logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
# START EXTRA
await ctx.send(embed=embeds_old.simple_question_300(
"EXTRAS: job status, zodiac sign, hobbies, etc. "
"Tell us about yourself!"),
content=f"Recorded answer: {dislikes}")
try:
extra_message = await self.client.wait_for('message', check=check,
timeout=300)
extra = extra_message.content
if len(extra) > 300:
extra = extra[:300]
extra = extra.replace("\n", " ")
logs.debug(f"{ctx.author.name} extra: {extra}")
# POST EXAMPLE EMBED AND FINAL IF APPROVED
em = embeds_old.final_embed_extended(ctx, nickname, age, location,
languages, pronouns, sexuality,
relationship_status, likes,
dislikes, extra)
view = interaction.Confirm(ctx)
await ctx.send(embed=em, content=f"Introduction of <@{ctx.author.id}>",
view=view)
await view.wait()
if view.clickedConfirm:
intro_channel = guild.get_channel(channel_id)
await intro_channel.send(embed=em,
content=f"Introduction of <@{ctx.author.id}>")
await ctx.send(embed=embeds_old.final_confirmation(channel_id))
logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
return
else:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
else:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
def setup(client):
client.add_cog(BasicCog(client))

View file

@ -1,35 +0,0 @@
import discord
from discord.ext import commands
from services.Xp import Xp
from lib import embeds_old, checks
class LevelCog(commands.Cog):
def __init__(self, client):
self.client = client
@commands.slash_command(
name="level",
description="Displays your level and server rank.",
guild_only=True
)
@commands.check(checks.channel)
async def level(self, ctx):
xp_data = Xp(ctx.author.id, ctx.guild.id)
rank = xp_data.calculate_rank()
needed_xp_for_next_level = Xp.xp_needed_for_next_level(xp_data.level)
embed = discord.Embed(color=0xadcca6,
title=f"Level {xp_data.level}")
embed.add_field(name=f"Progress to next level",
value=Xp.generate_progress_bar(xp_data.xp, needed_xp_for_next_level), inline=False)
embed.set_footer(text=f"Server Rank: #{rank}")
embed.set_thumbnail(url=ctx.author.display_avatar)
await ctx.respond(embed=embed, content=ctx.author.mention)
def setup(client):
client.add_cog(LevelCog(client))

View file

@ -0,0 +1,37 @@
from discord.ext import commands, bridge
from lib import checks
from modules.levels import level, leaderboard
class Levels(commands.Cog):
def __init__(self, client):
self.client = client
@bridge.bridge_command(
name="level",
aliases=["rank", "lvl"],
description="Displays your level and server rank.",
help="Displays your level and rank in the current server.",
guild_only=True
)
@commands.check(checks.channel)
async def level_command(self, ctx):
await level.cmd(ctx)
@bridge.bridge_command(
name="leaderboard",
aliases=["lb", "xplb"],
description="Are ya winning' son?",
help="Shows the guild's level leaderboard by default. You can switch to currency and /daily leaderboard.",
guild_only=True
)
@commands.check(checks.channel)
@commands.cooldown(1, 180, commands.BucketType.user)
async def leaderboard_command(self, ctx):
return await leaderboard.cmd(ctx)
def setup(client):
client.add_cog(Levels(client))

18
modules/levels/level.py Normal file
View file

@ -0,0 +1,18 @@
import discord
from services.Xp import Xp
async def cmd(ctx):
xp_data = Xp(ctx.author.id, ctx.guild.id)
rank = xp_data.calculate_rank()
needed_xp_for_next_level = Xp.xp_needed_for_next_level(xp_data.level)
embed = discord.Embed(color=0xadcca6, title=f"Level {xp_data.level}")
embed.add_field(name=f"Progress to next level",
value=Xp.generate_progress_bar(xp_data.xp, needed_xp_for_next_level), inline=False)
embed.set_footer(text=f"Server Rank: #{rank}")
embed.set_thumbnail(url=ctx.author.display_avatar)
await ctx.respond(embed=embed, content=ctx.author.mention)

View file

@ -1,14 +1,9 @@
import logging
import discord
import datetime
from discord.ext import commands, bridge
import datetime, time
from lib.embeds.info import MiscInfo
from lib import checks
from main import strings
logs = logging.getLogger('Racu.Core')
from lib.embeds.info import MiscInfo
from lib.embeds.error import GenericErrors
from modules.misc import introduction
class Misc(commands.Cog):
@ -41,6 +36,26 @@ class Misc(commands.Cog):
unix_timestamp = int(round(self.start_time.timestamp()))
return await ctx.respond(embed=MiscInfo.uptime(ctx, self.client, unix_timestamp))
@bridge.bridge_command(
name="introduction",
aliases=["intro", "introduce"],
guild_only=False,
description="This command can only be done in DMs.",
help="Introduce yourself to a server. For now this command "
"can only be done in ONE server and only as a __slash command in Racu's DMs__."
)
@commands.dm_only()
async def intro_command(self, ctx):
return await introduction.cmd(self, ctx)
@intro_command.error
async def on_command_error(self, ctx, error):
if isinstance(error, commands.PrivateMessageOnly):
await ctx.respond(embed=GenericErrors.private_message_only(ctx))
else:
await ctx.respond(embed=GenericErrors.default_exception(ctx))
raise error
def setup(client):
client.add_cog(Misc(client))

View file

@ -0,0 +1,381 @@
import asyncio
import logging
import os
import subprocess
import discord
from discord.ext import commands
from lib import interaction, embeds_old, checks
logs = logging.getLogger('Racu.Core')
async def cmd(self, ctx):
# rewrite this whole command
guild_id = 719227135151046699
channel_id = 973619250507972618
guild = self.client.get_guild(guild_id)
try:
member = await guild.fetch_member(ctx.author.id)
except discord.HTTPException:
return await ctx.respond("You can't do this command because you're not "
"in a server that supports introductions.")
embed = discord.Embed(color=0xadcca6,
title=f"Hey {ctx.author.name}!",
description=f"This command will serve as a questionnaire "
f"for your entry to <#{channel_id}>. Please keep your answers \"PG-13.\"")
embed.add_field(name="Short intro", value="Click the blue button to use the short form, this one has "
"__6 questions__, which is filled out promptly & contains the "
"most important elements needed to briefly describe you.")
embed.add_field(name="Extended intro", value="Click the green button to fill out an extended form with "
"__10 questions__ (including an \"extras\" field where you "
"can unleash your creativity), this one takes a bit longer "
"to fill out but gives a more detailed portrayal of you.")
embed.set_footer(text="Please don't abuse this command.")
embed.set_thumbnail(url="https://cdn.discordapp.com/icons/719227135151046699/49df8c284382af9dbcfd629c8eadc52c"
".webp?size=96")
view = interaction.IntroButtons(ctx)
await ctx.respond(embed=embed, view=view)
await view.wait()
def check(message):
return message.author == ctx.author and isinstance(message.channel, discord.DMChannel)
if view.clickedShort:
logs.debug(f"{ctx.author.name} clicked Short Intro")
# START NICKNAME
await ctx.send(embed=embeds_old.simple_question_first("How would you like to be identified in the server?"))
try:
nickname_message = await self.client.wait_for('message', check=check, timeout=120)
nickname = nickname_message.content
if len(nickname) > 100:
nickname = nickname[:100]
nickname = nickname.replace("\n", " ")
logs.debug(f"{ctx.author.name} nickname: {nickname}")
# START AGE
await ctx.send(embed=embeds_old.simple_question_5("How old are you?"),
content=f"Recorded answer: {nickname}")
try:
age_message = await self.client.wait_for('message', check=check, timeout=120)
age = age_message.content
if len(age) > 5:
age = age[:5]
age = age.replace("\n", " ")
logs.debug(f"{ctx.author.name} age: {age}")
# START LOCATION
view = interaction.LocationOptions(ctx)
await ctx.send(embed=embeds_old.simple_question_none("Where do you live?"),
view=view,
content=f"Recorded answer: {age}")
await view.wait()
location = view.location
if not view.location:
await ctx.send(embed=embeds_old.no_time())
return
logs.debug(f"{ctx.author.name} location: {location}")
# START PRONOUNS
await ctx.send(
embed=embeds_old.simple_question_30("What are your preferred pronouns?"),
content=f"Recorded answer: {location}")
try:
pronouns_message = await self.client.wait_for('message', check=check, timeout=120)
pronouns = pronouns_message.content
if len(pronouns) > 30:
pronouns = pronouns[:30]
pronouns = pronouns.replace("\n", " ")
logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
# START LIKES
await ctx.send(embed=embeds_old.simple_question_300("Likes & interests"),
content=f"Recorded answer: {pronouns}")
try:
likes_message = await self.client.wait_for('message', check=check, timeout=300)
likes = likes_message.content
if len(likes) > 300:
likes = likes[:300]
likes = likes.replace("\n", " ")
logs.debug(f"{ctx.author.name} likes: {likes}")
# START DISLIKES
await ctx.send(embed=embeds_old.simple_question_300("Dislikes"),
content=f"Recorded answer: {likes}")
try:
dislikes_message = await self.client.wait_for('message', check=check, timeout=300)
dislikes = dislikes_message.content
if len(dislikes) > 300:
dislikes = dislikes[:300]
dislikes = dislikes.replace("\n", " ")
logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
# POST EXAMPLE EMBED AND FINAL IF APPROVED
em = embeds_old.final_embed_short(ctx, nickname, age, location, pronouns, likes, dislikes)
view = interaction.Confirm(ctx)
await ctx.send(embed=em, content=f"Introduction of <@{ctx.author.id}>", view=view)
await view.wait()
if view.clickedConfirm:
intro_channel = guild.get_channel(channel_id)
await intro_channel.send(embed=em, content=f"Introduction of <@{ctx.author.id}>")
await ctx.send(embed=embeds_old.final_confirmation(channel_id))
logs.info(f"[CommandHandler] {ctx.author.name} introduction was submitted.")
return
else:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
elif view.clickedLong:
logs.debug(f"{ctx.author.name} clicked Long Intro")
# START NICKNAME
await ctx.send(embed=embeds_old.simple_question_first_extended(
"How would you like to be identified in the server?"))
try:
nickname_message = await self.client.wait_for('message', check=check, timeout=120)
nickname = nickname_message.content
if len(nickname) > 100:
nickname = nickname[:100]
nickname = nickname.replace("\n", " ")
logs.debug(f"{ctx.author.name} nickname: {nickname}")
# START AGE
await ctx.send(embed=embeds_old.simple_question_5("How old are you?"),
content=f"Recorded answer: {nickname}")
try:
age_message = await self.client.wait_for('message', check=check, timeout=120)
age = age_message.content
if len(age) > 5:
age = age[:5]
age = age.replace("\n", " ")
logs.debug(f"{ctx.author.name} age: {age}")
# START LOCATION
view = interaction.LocationOptions(ctx)
await ctx.send(embed=embeds_old.simple_question_none("Where do you live?"),
view=view,
content=f"Recorded answer: {age}")
await view.wait()
location = view.location
if not view.location:
await ctx.send(embed=embeds_old.no_time())
return
logs.debug(f"{ctx.author.name} location: {location}")
# START LANGUAGES
await ctx.send(
embed=embeds_old.simple_question_100("Which languages do you speak?"),
content=f"Recorded answer: {location}"
)
try:
languages_message = await self.client.wait_for('message', check=check, timeout=200)
languages = languages_message.content
if len(languages) > 30:
languages = languages[:30]
languages = languages.replace("\n", " ")
logs.debug(f"{ctx.author.name} languages: {languages}")
# START PRONOUNS
await ctx.send(
embed=embeds_old.simple_question_30("What are your preferred pronouns?"),
content=f"Recorded answer: {languages}")
try:
pronouns_message = await self.client.wait_for('message', check=check, timeout=120)
pronouns = pronouns_message.content
if len(pronouns) > 30:
pronouns = pronouns[:30]
pronouns = pronouns.replace("\n", " ")
logs.debug(f"{ctx.author.name} pronouns: {pronouns}")
# START SEXUALITY
await ctx.send(
embed=embeds_old.simple_question_30("What's your sexuality?"),
content=f"Recorded answer: {pronouns}")
try:
sexuality_message = await self.client.wait_for('message', check=check, timeout=120)
sexuality = sexuality_message.content
if len(sexuality) > 30:
sexuality = sexuality[:30]
sexuality = sexuality.replace("\n", " ")
logs.debug(f"{ctx.author.name} sexuality: {sexuality}")
# START RELATIONSHIP_STATUS
await ctx.send(
embed=embeds_old.simple_question_30("What's your current relationship status?"),
content=f"Recorded answer: {sexuality}")
try:
relationship_status_message = await self.client.wait_for('message', check=check,
timeout=120)
relationship_status = relationship_status_message.content
if len(relationship_status) > 30:
relationship_status = relationship_status[:30]
relationship_status = relationship_status.replace("\n", " ")
logs.debug(f"{ctx.author.name} relationship_status: {relationship_status}")
# START LIKES
await ctx.send(embed=embeds_old.simple_question_300("Likes & interests"),
content=f"Recorded answer: {relationship_status}")
try:
likes_message = await self.client.wait_for('message', check=check, timeout=300)
likes = likes_message.content
if len(likes) > 300:
likes = likes[:300]
likes = likes.replace("\n", " ")
logs.debug(f"{ctx.author.name} likes: {likes}")
# START DISLIKES
await ctx.send(embed=embeds_old.simple_question_300("Dislikes"),
content=f"Recorded answer: {likes}")
try:
dislikes_message = await self.client.wait_for('message', check=check,
timeout=300)
dislikes = dislikes_message.content
if len(dislikes) > 300:
dislikes = dislikes[:300]
dislikes = dislikes.replace("\n", " ")
logs.debug(f"{ctx.author.name} dislikes: {dislikes}")
# START EXTRA
await ctx.send(embed=embeds_old.simple_question_300(
"EXTRAS: job status, zodiac sign, hobbies, etc. "
"Tell us about yourself!"),
content=f"Recorded answer: {dislikes}")
try:
extra_message = await self.client.wait_for('message', check=check,
timeout=300)
extra = extra_message.content
if len(extra) > 300:
extra = extra[:300]
extra = extra.replace("\n", " ")
logs.debug(f"{ctx.author.name} extra: {extra}")
# POST EXAMPLE EMBED AND FINAL IF APPROVED
em = embeds_old.final_embed_extended(ctx, nickname, age, location,
languages, pronouns, sexuality,
relationship_status, likes,
dislikes, extra)
view = interaction.Confirm(ctx)
await ctx.send(embed=em, content=f"Introduction of <@{ctx.author.id}>",
view=view)
await view.wait()
if view.clickedConfirm:
intro_channel = guild.get_channel(channel_id)
await intro_channel.send(embed=em,
content=f"Introduction of <@{ctx.author.id}>")
await ctx.send(embed=embeds_old.final_confirmation(channel_id))
logs.info(
f"[CommandHandler] {ctx.author.name} introduction was submitted.")
return
else:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
except asyncio.TimeoutError:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return
else:
await ctx.send(embed=embeds_old.no_time())
logs.warning(f"{ctx.author.id} Intro Timeout")
return

View file

@ -1,54 +0,0 @@
import json
import os
import sqlite3
import discord
from discord.ext import commands
from dotenv import load_dotenv
from db import database
from lib import checks
load_dotenv('.env')
with open("config/economy.json") as file:
json_data = json.load(file)
class OwnerOnlyCog(commands.Cog):
def __init__(self, client):
self.client = client
sql = discord.SlashCommandGroup(name="sql", description="Perform SQL commands (DANGEROUS)", guild_only=True)
@sql.command(
name="select",
description="Perform a SELECT query in the database."
)
@commands.check(checks.bot_owner)
async def select(self, ctx, *, query: discord.Option(str)):
if query.lower().startswith("select "):
query = query[7:]
try:
results = database.select_query(f"SELECT {query}")
except sqlite3.Error as error:
results = error
return await ctx.respond(content=f"```SELECT {query}```\n```{results}```", ephemeral=True)
@sql.command(
name="inject",
description="Change a value in the database. (DANGEROUS)"
)
@commands.check(checks.bot_owner)
async def inject(self, ctx, *, query: discord.Option(str)):
try:
database.execute_query(query)
await ctx.respond(content=f"That worked!\n```{query}```", ephemeral=True)
except sqlite3.Error as error:
await ctx.respond(content=f"Query:\n```{query}```\nError message:\n```{error}```", ephemeral=True)
def setup(client):
client.add_cog(OwnerOnlyCog(client))