Skip to content

Commit ef2c35d

Browse files
Deploy ready branch
1 parent 7319844 commit ef2c35d

12 files changed

+25
-26
lines changed

.gitmodules

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,3 @@
1+
[submodule "shared_migrations"]
2+
path = shared_migrations
3+
url = https://github.com/Code4GovTech/shared-models-migrations.git

cogs/badges.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@
33
import discord
44
from discord.ext import commands
55

6-
from helpers.supabaseClient import PostgresClient
6+
from shared_migrations.db.discord_bot import DiscordBotQueries
77

88

99
class BadgeModal(discord.ui.Modal, title="Your Badges"):
@@ -17,7 +17,7 @@ async def on_timeout(self, interaction):
1717

1818
class BadgeContents:
1919
def __init__(self, name) -> None:
20-
self.postgres_client = PostgresClient()
20+
self.postgres_client = DiscordBotQueries()
2121
apprentinceDesc = f"""Welcome *{name}*!!
2222
2323

cogs/discordDataScraper.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@
99
from discord.channel import TextChannel
1010
from discord.ext import commands, tasks
1111

12-
from helpers.supabaseClient import PostgresClient
12+
from shared_migrations.db.discord_bot import DiscordBotQueries
1313

1414
with open("config.json") as config_file:
1515
config_data = json.load(config_file)
@@ -24,7 +24,7 @@
2424
class DiscordDataScaper(commands.Cog):
2525
def __init__(self, bot) -> None:
2626
self.bot = bot
27-
self.postgres_client = PostgresClient()
27+
self.postgres_client = DiscordBotQueries()
2828

2929
@commands.Cog.listener()
3030
async def on_message(self, message):

cogs/listeners/member_events_cog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import discord
22
from discord.ext import commands
33

4-
from helpers.supabaseClient import PostgresClient
5-
4+
from shared_migrations.db.discord_bot import DiscordBotQueries
65

76
class MemberEventsListener(commands.Cog):
87
def __init__(self, bot) -> None:
98
self.bot = bot
10-
self.postgres_client = PostgresClient()
9+
self.postgres_client = DiscordBotQueries()
1110
super().__init__()
1211

1312
@commands.Cog.listener("on_member_join")

cogs/listeners/message_events_cog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,9 @@
22
from discord.ext import commands
33

44
from config.server import ServerConfig
5-
from helpers.supabaseClient import PostgresClient
6-
5+
from shared_migrations.db.discord_bot import DiscordBotQueries
76
serverConfig = ServerConfig()
8-
postgresClient = PostgresClient()
7+
postgresClient = DiscordBotQueries()
98

109

1110
async def grantVerifiedRole(member: discord.Member):

cogs/listeners/role_events_cog.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,12 @@
11
import discord
22
from discord.ext import commands
33

4-
from helpers.supabaseClient import PostgresClient
5-
4+
from shared_migrations.db.discord_bot import DiscordBotQueries
65

76
class RoleEventsListener(commands.Cog):
87
def __init__(self, bot) -> None:
98
self.bot = bot
10-
self.postgres_client = PostgresClient()
9+
self.postgres_client = DiscordBotQueries()
1110
super().__init__()
1211

1312
@commands.Cog.listener()

cogs/serverManagement.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,15 +3,14 @@
33
from discord.ext import commands, tasks
44

55
from config.server import ServerConfig
6-
from helpers.supabaseClient import PostgresClient
7-
6+
from shared_migrations.db.discord_bot import DiscordBotQueries
87
serverConfig = ServerConfig()
98

109

1110
class ServerManagement(commands.Cog):
1211
def __init__(self, bot):
1312
self.bot: commands.Bot = bot
14-
self.postgres_client = PostgresClient()
13+
self.postgres_client = DiscordBotQueries()
1514

1615
def validUser(self, ctx):
1716
authorised_users = [

cogs/userInteractions.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@
55
from discord.ext import commands, tasks
66
from dotenv import find_dotenv, load_dotenv
77

8-
from helpers.supabaseClient import PostgresClient
8+
from shared_migrations.db.discord_bot import DiscordBotQueries
99

1010
load_dotenv(find_dotenv())
1111

@@ -16,7 +16,7 @@ class UserHandler(commands.Cog):
1616
def __init__(self, bot) -> None:
1717
self.bot = bot
1818
self.update_contributors.start()
19-
self.postgres_client = PostgresClient()
19+
self.postgres_client = DiscordBotQueries()
2020

2121
@tasks.loop(minutes=60)
2222
async def update_contributors(self):

cogs/vcCog.py

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -6,8 +6,7 @@
66
from discord.ext import commands
77

88
from config.server import ServerConfig
9-
from helpers.supabaseClient import PostgresClient
10-
9+
from shared_migrations.db.discord_bot import DiscordBotQueries
1110
"""
1211
with io.BytesIO(image_bytes) as image_file:
1312
# Create a discord.File object from this file-like object
@@ -21,7 +20,7 @@
2120
class CommunityVCView(ui.View):
2221
def __init__(self, *, timeout=None):
2322
super().__init__(timeout=timeout)
24-
self.postgres_client = PostgresClient()
23+
self.postgres_client = DiscordBotQueries()
2524

2625
def isCommunityContributor(self, roles: list[Role]):
2726
CommunityContributorRoleID = ServerConfig.Roles.CONTRIBUTOR_ROLE
@@ -215,7 +214,7 @@ async def serveCertificateLink(self, interaction: Interaction, button: ui.Button
215214

216215
class VCProgramSelection(ui.View):
217216
def __init__(self, *, timeout=None):
218-
self.postgres_client = PostgresClient()
217+
self.postgres_client = DiscordBotQueries()
219218
super().__init__(timeout=timeout)
220219

221220
async def resetSelectMenu(self, interaction):

helpers/supabaseClient.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@
66
from dotenv import load_dotenv
77
from sqlalchemy import create_engine,select,desc,update,delete
88
from sqlalchemy.orm import sessionmaker
9-
from models import *
9+
from shared_migrations.db.models import *
1010
from sqlalchemy.ext.declarative import DeclarativeMeta
1111
from sqlalchemy.ext.asyncio import create_async_engine, AsyncSession
1212

main.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
from discord.ext import commands
88

99
from cogs.vcCog import VCProgramSelection
10-
from helpers.supabaseClient import PostgresClient
10+
from shared_migrations.db.discord_bot import DiscordBotQueries
1111
from dotenv import load_dotenv, find_dotenv
1212

1313

@@ -70,7 +70,7 @@ async def on_submit(self, interaction: discord.Interaction):
7070
except Exception as e:
7171
print('exception e ', e)
7272
try:
73-
response = await PostgresClient().updateContributor(user_data)
73+
response = await DiscordBotQueries().updateContributor(user_data)
7474
print("DB updated for user:", user_data["discord_id"])
7575
except Exception as e:
7676
print("Failed to update credentials for user: "+e)
@@ -96,7 +96,7 @@ async def hasIntroduced():
9696
while not authentication:
9797
print("Not authenticated. Waiting")
9898
await asyncio.sleep(15)
99-
authentication = await PostgresClient().read("contributors_registration", "discord_id", user.id)
99+
authentication = await DiscordBotQueries().read("contributors_registration", "discord_id", user.id)
100100
print("User has authenticated")
101101
return True
102102

shared_migrations

Submodule shared_migrations added at 0dedd5a

0 commit comments

Comments
 (0)