Skip to content

Commit

Permalink
Merge pull request #189 from MiscGuild/bug_fix
Browse files Browse the repository at this point in the history
feat: moved db loading to discord utils from loop_utils
  • Loading branch information
Amxgh authored May 25, 2024
2 parents c0e2214 + 286459b commit 3b5dfea
Show file tree
Hide file tree
Showing 3 changed files with 4 additions and 10 deletions.
1 change: 0 additions & 1 deletion src/utils/db_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,6 @@

async def connect_db():
bot.db = await aiosqlite.connect("database.db")

# Discord Member Table:
await bot.db.execute("""CREATE TABLE IF NOT EXISTS members (
discord_id integer PRIMARY KEY NOT NULL,
Expand Down
8 changes: 4 additions & 4 deletions src/utils/discord_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

from src.utils.consts import (config, log_channel_id, neutral_color, ticket_categories,
guild_handle)
from src.utils.db_utils import check_uuid_in_db
from src.utils.db_utils import check_uuid_in_db, connect_db
from src.utils.request_utils import get_mojang_profile
from src.utils.ticket_utils import *
from src.utils.ticket_utils.tickets import name_grabber
Expand Down Expand Up @@ -162,7 +162,6 @@ async def after_cache_ready():
# Set owner id(s) and guild
bot.owner_ids = config["owner_ids"]
bot.guild = bot.get_guild(config["guild_id"])

# Set roles
bot.admin = discord.utils.get(bot.guild.roles, name="Admin")
bot.staff = discord.utils.get(bot.guild.roles, name="Staff")
Expand All @@ -184,14 +183,15 @@ async def after_cache_ready():
bot.tag_allowed_roles = (bot.active_role, bot.staff, bot.former_staff,
bot.server_booster, bot.rich_kid, bot.gvg, bot.veteran, bot.recruiter)

from src.utils.discord_utils import name_grabber
bot.staff_names = [(await get_mojang_profile(await name_grabber(member)))[0] for member in bot.staff.members]
await connect_db()

from src.utils.loop_utils import check_giveaways, send_gexp_lb, update_invites
check_giveaways.start()
send_gexp_lb.start()
update_invites.start()

from src.utils.discord_utils import name_grabber
bot.staff_names = [(await get_mojang_profile(await name_grabber(member)))[0] for member in bot.staff.members]

@after_cache_ready.before_loop
async def before_cache_loop():
Expand Down
5 changes: 0 additions & 5 deletions src/utils/loop_utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,11 +31,6 @@ async def check_giveaways():
await bot.db.commit()


@check_giveaways.before_loop
async def before_giveaway_check():
await bot.wait_until_ready()
await connect_db()


@tasks.loop(hours=24)
async def send_gexp_lb():
Expand Down

0 comments on commit 3b5dfea

Please sign in to comment.