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

Up version

This commit is contained in:
wlinator 2024-08-14 06:37:48 -04:00
parent 5c9f1973e9
commit 1be8179399
4 changed files with 29 additions and 47 deletions

View file

@ -12,7 +12,7 @@ class Constants:
TITLE = "Luminara"
AUTHOR = "wlinator"
LICENSE = "GNU General Public License v3.0"
VERSION = "2.8.7" # "Refactor: Pycord 2.6" update
VERSION = "2.8.8" # "Refactor: v2.8" update
# bot credentials
TOKEN: Optional[str] = os.environ.get("TOKEN", None)

View file

@ -57,8 +57,7 @@ class Inventory:
def get_item_quantity(self, item: item_service.Item):
query = "SELECT COALESCE(quantity, 0) FROM inventory WHERE user_id = %s AND item_id = %s"
result = database.select_query_one(query, (self.user_id, item.id))
return result
return database.select_query_one(query, (self.user_id, item.id))
def get_sell_data(self):
query = """
@ -70,13 +69,8 @@ class Inventory:
"""
try:
item_names = []
results = database.select_query(query, (self.user_id,))
for item in results:
item_names.append(item[0])
return item_names
return [item[0] for item in results]
except Exception as e:
logger.error(e)

View file

@ -26,17 +26,14 @@ class Item:
WHERE id = %s
"""
data = database.select_query(query, (self.id,))[0]
return data
return database.select_query(query, (self.id,))[0]
def get_quantity(self, author_id):
query = """
SELECT COALESCE((SELECT quantity FROM inventory WHERE user_id = %s AND item_id = %s), 0) AS quantity
"""
quantity = database.select_query_one(query, (author_id, self.id))
return quantity
return database.select_query_one(query, (author_id, self.id))
def get_item_worth(self):
query = """
@ -52,13 +49,8 @@ class Item:
query = "SELECT display_name FROM item"
try:
item_names = []
items = database.select_query(query)
for item in items:
item_names.append(item[0])
return item_names
return [item[0] for item in items]
except sqlite3.Error:
logger.error(sqlite3.Error)

View file

@ -1,4 +1,4 @@
from datetime import datetime
from datetime import datetime, timezone
from typing import Any, Dict, List, Optional
from db import database
@ -23,11 +23,10 @@ class CustomReactionsService:
ORDER BY guild_id = %s DESC, is_global ASC
LIMIT 1
"""
result = database.select_query(
if result := database.select_query(
query,
(guild_id, message_content, message_content, guild_id),
)
if result:
):
reaction = result[0] # Get the first result from the list
return {
"id": reaction[0],
@ -52,8 +51,7 @@ class CustomReactionsService:
WHERE id = %s
LIMIT 1
"""
result = database.select_query(query, (reaction_id,))
if result:
if result := database.select_query(query, (reaction_id,)):
reaction = result[0] # Get the first result from the list
return {
"id": reaction[0],
@ -78,26 +76,24 @@ class CustomReactionsService:
WHERE guild_id = %s
"""
results = database.select_query(query, (guild_id,))
reactions = []
for reaction in results:
reactions.append(
{
"id": reaction[0],
"trigger_text": reaction[1],
"response": reaction[2],
"emoji_id": reaction[3],
"is_emoji": reaction[4],
"is_full_match": reaction[5],
"is_global": reaction[6],
"guild_id": reaction[7],
"creator_id": reaction[8],
"usage_count": reaction[9],
"created_at": reaction[10],
"updated_at": reaction[11],
"type": "emoji" if reaction[4] else "text",
},
)
return reactions
return [
{
"id": reaction[0],
"trigger_text": reaction[1],
"response": reaction[2],
"emoji_id": reaction[3],
"is_emoji": reaction[4],
"is_full_match": reaction[5],
"is_global": reaction[6],
"guild_id": reaction[7],
"creator_id": reaction[8],
"usage_count": reaction[9],
"created_at": reaction[10],
"updated_at": reaction[11],
"type": "emoji" if reaction[4] else "text",
}
for reaction in results
]
async def create_custom_reaction(
self,
@ -160,7 +156,7 @@ class CustomReactionsService:
is_emoji,
is_full_match,
is_global,
datetime.utcnow(),
datetime.now(timezone.utc),
reaction_id,
),
)