Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backend redo #186

Merged
merged 2 commits into from
Apr 8, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion src/func/General.py
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@
resident_req, dnkl_entries_not_found,
positive_responses, allies)
from src.utils.db_utils import insert_new_giveaway, select_all, get_db_username_from_uuid, \
get_db_uuid_username_from_discord_id, insert_new_member, select_one
get_db_uuid_username_from_discord_id, insert_new_member, select_one, update_member
from src.utils.discord_utils import (create_ticket,
get_ticket_creator, log_event,
name_grabber, has_tag_perms)
Expand Down Expand Up @@ -107,6 +107,11 @@ async def rolecheck(ctx, send_ping: bool):

nick = await name_grabber(discord_member)
uuid, username = await get_db_uuid_username_from_discord_id(discord_member.id)
if not uuid and username:
username, uuid = await get_mojang_profile(username)
if username and uuid:
await update_member(discord_member.id, uuid, username)

if not uuid and not username:
await discord_member.remove_roles(bot.member_role, bot.ally, bot.guest, bot.active_role)
await discord_member.add_roles(bot.new_member_role)
Expand Down
2 changes: 1 addition & 1 deletion src/utils/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -143,7 +143,7 @@ async def insert_new_member(discord_id: int, uuid: str, username: str):
async def update_member(discord_id: int, uuid: str, username: str):
discord_idExists = await select_one("SELECT uuid from members WHERE discord_id = (?)", (discord_id,))
if discord_idExists:
await bot.db.execute("UPDATE members SET uuid = (?) and username = (?) WHERE discord_id = (?)",
await bot.db.execute("UPDATE members SET uuid = ?, username = ? WHERE discord_id = ?",
(uuid, username, discord_id))
await bot.db.commit()
else:
Expand Down
Loading