Skip to content

Commit

Permalink
hotfix: discord verified contributors
Browse files Browse the repository at this point in the history
  • Loading branch information
KDwevedi committed Dec 7, 2023
1 parent 8ca71c3 commit 99cad20
Show file tree
Hide file tree
Showing 3 changed files with 12 additions and 9 deletions.
4 changes: 2 additions & 2 deletions cogs/badges.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,7 +97,7 @@ def get_user_badges(self, discord_id):
"points": [],
"achievements": []
}
if len(SupabaseInterface("contributors").read(query_key="discord_id", query_value=discord_id))>0:
if len(SupabaseInterface("contributors_registration").read(query_key="discord_id", query_value=discord_id))>0:
userBadges["achievements"].append(self.discordXGithubBadge)

discordMemberData = SupabaseInterface("discord_engagement").read("contributor", discord_id)
Expand All @@ -108,7 +108,7 @@ def get_user_badges(self, discord_id):
userBadges["achievements"].append(self.rockstarBadge)
if discordMemberData[0]["has_introduced"]:
userBadges["achievements"].append(self.apprenticeBadge)
contributorData = SupabaseInterface("contributors").read(query_key="discord_id", query_value=discord_id)
contributorData = SupabaseInterface("contributors_registration").read(query_key="discord_id", query_value=discord_id)
if contributorData:
github_id = contributorData[0]["github_id"]
prData = {
Expand Down
15 changes: 9 additions & 6 deletions cogs/user_interactions.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,7 +66,7 @@ def __init__(self, discord_userdata):
class UserHandler(commands.Cog):
def __init__(self, bot) -> None:
self.bot = bot
# self.update_contributors.start()
self.update_contributors.start()



Expand Down Expand Up @@ -118,11 +118,14 @@ async def list_badges(self, ctx):

@tasks.loop(minutes=10)
async def update_contributors(self):
contributors = SupabaseInterface("contributors").read_all()
guild = await self.bot.fetch_guild(os.getenv("SERVER_ID"))
contributor_role = guild.get_role(VERIFIED_CONTRIBUTOR_ROLE_ID)
contributors = SupabaseInterface("contributors_registration").read_all()
guild = await self.bot.fetch_guild(973851473131761674)
contributor_role:discord.Role = guild.get_role(VERIFIED_CONTRIBUTOR_ROLE_ID)
for contributor in contributors:
member = await guild.fetch_member(contributor["discord_id"])
try:
member = await guild.fetch_member(contributor["discord_id"])
except Exception:
continue
if contributor_role not in member.roles:
#Give Contributor Role
await member.add_roles(contributor_role)
Expand Down Expand Up @@ -330,7 +333,7 @@ async def point_breakdown(self, ctx):
async def get_points(self, ctx):
if isinstance(ctx.channel, discord.DMChannel):
discord_id = ctx.author.id
contributor = SupabaseInterface(table="contributors").read(query_key="discord_id", query_value=discord_id)
contributor = SupabaseInterface(table="contributors_registration").read(query_key="discord_id", query_value=discord_id)
print(contributor)
github_id = contributor[0]["github_id"]
prs_raised = SupabaseInterface(table="pull_requests").read(query_key="raised_by", query_value=github_id)
Expand Down
2 changes: 1 addition & 1 deletion main.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ async def on_submit(self, interaction: discord.Interaction):
else:
async def hasIntroduced():
print("Checking...")
authentication = SupabaseInterface("contributors").read("discord_id", user.id)
authentication = SupabaseInterface("contributors_registration").read("discord_id", user.id)
while not authentication:
await asyncio.sleep(30)
print("Found!")
Expand Down

0 comments on commit 99cad20

Please sign in to comment.