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

refactor Group members #7

Merged
merged 2 commits into from
Dec 26, 2020
Merged
Show file tree
Hide file tree
Changes from 1 commit
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
Next Next commit
Refactor groupmembers
  • Loading branch information
A-Phamfam committed Dec 26, 2020
commit 0c99d2111f52e92bcfd95105be2b2bb8e50ecd58
867 changes: 9 additions & 858 deletions Utility.py

Large diffs are not rendered by default.

6 changes: 3 additions & 3 deletions module/BiasGame.py
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ async def listbg(self, ctx, user: discord.Member = None):
msg_string = f"**Bias Game Leaderboard for {user.display_name}**:\n"
counter = 1
for idol_id, wins in user_wins:
member = await ex.get_member(idol_id)
member = await ex.u_group_members.get_member(idol_id)
msg_string += f"{counter}) {member.full_name} ({member.stage_name}) -> {wins} Win(s).\n"
counter += 1
else:
Expand Down Expand Up @@ -131,11 +131,11 @@ async def create_new_question(self):
for first_idol, second_idol in self.current_bracket_teams:
if not self.force_ended:
try:
first_idol_group = (await ex.get_group(random.choice(first_idol.groups))).name
first_idol_group = (await ex.u_group_members.get_group(random.choice(first_idol.groups))).name
except Exception as e:
first_idol_group = first_idol.full_name
try:
second_idol_group = (await ex.get_group(random.choice(second_idol.groups))).name
second_idol_group = (await ex.u_group_members.get_group(random.choice(second_idol.groups))).name
except Exception as e:
second_idol_group = second_idol.full_name

Expand Down
20 changes: 10 additions & 10 deletions module/BotMod.py
Original file line number Diff line number Diff line change
Expand Up @@ -115,8 +115,8 @@ async def mergeidol(self, ctx, original_idol_id: int, duplicate_idol_id: int):
all of it's connections.
[Format: %mergeidol (original idol id) (duplicate idol id)]"""
# check groups
original_idol = await ex.get_member(original_idol_id)
duplicate_idol = await ex.get_member(duplicate_idol_id)
original_idol = await ex.u_group_members.get_member(original_idol_id)
duplicate_idol = await ex.u_group_members.get_member(duplicate_idol_id)

if not duplicate_idol:
return await ctx.send(f"> {duplicate_idol_id} could not find an Idol.")
Expand All @@ -141,8 +141,8 @@ async def mergegroup(self, ctx, original_group_id: int, duplicate_group_id: int)
If an idol ID is not in the original group, it will be added and then this group will be deleted along with
all of it's connections.
[Format: %mergegroup (original group id) (duplicate group id)]"""
original_group = await ex.get_group(original_group_id)
duplicate_group = await ex.get_group(duplicate_group_id)
original_group = await ex.u_group_members.get_group(original_group_id)
duplicate_group = await ex.u_group_members.get_group(duplicate_group_id)
if not duplicate_group:
return await ctx.send(f"> {duplicate_group_id} could not find a Group.")
if not original_group:
Expand Down Expand Up @@ -312,12 +312,12 @@ async def removestatus(self, ctx, status_index: int):
async def addidoltogroup(self, ctx, idol_id: int, group_id: int):
"""Adds idol to group. [Format: %addidoltogroup (idol id) (group id)"""
try:
member_name = (await ex.get_member(idol_id))[1]
member_name = (await ex.u_group_members.get_member(idol_id))[1]
group_name = await ex.get_group_name(group_id)
if await ex.check_member_in_group(idol_id, group_id):
return await ctx.send(f'> **{member_name} ({idol_id}) is already in {group_name} ({group_id}).**')
else:
await ex.add_idol_to_group(idol_id, group_id)
await ex.u_group_members.add_idol_to_group(idol_id, group_id)
await ctx.send(f"**Added {member_name} ({idol_id}) to {group_name} ({group_id}).**")
except Exception as e:
await ctx.send(f"Something went wrong - {e}")
Expand All @@ -328,12 +328,12 @@ async def addidoltogroup(self, ctx, idol_id: int, group_id: int):
async def deleteidolfromgroup(self, ctx, idol_id: int, group_id: int):
"""Deletes idol from group. [Format: %deleteidolfromgroup (idol id) (group id)"""
try:
member_name = (await ex.get_member(idol_id))[1]
member_name = (await ex.u_group_members.get_member(idol_id))[1]
group_name = await ex.get_group_name(group_id)
if not await ex.check_member_in_group(idol_id, group_id):
await ctx.send(f"> **{member_name} ({idol_id}) is not in {group_name} ({group_id}).**")
else:
await ex.remove_idol_from_group(idol_id, group_id)
await ex.u_group_members.remove_idol_from_group(idol_id, group_id)
await ctx.send(f"**Removed {member_name} ({idol_id}) from {group_name} ({group_id}).**")
except Exception as e:
await ctx.send(f"Something went wrong - {e}")
Expand All @@ -349,7 +349,7 @@ async def addidol(self, ctx, full_name, stage_name, group_id: int):
group_name = await ex.get_group_name(group_id)
await ex.conn.execute("INSERT INTO groupmembers.member (fullname, stagename) VALUES($1, $2)", full_name, stage_name)
idol_id = await ex.get_idol_id_by_both_names(full_name, stage_name)
await ex.add_idol_to_group(idol_id, group_id)
await ex.u_group_members.add_idol_to_group(idol_id, group_id)
await ctx.send(f"{full_name} was added and is in {group_name} ({group_id}).")
except Exception as e:
await ctx.send(f"Something went wrong - {e}")
Expand All @@ -360,7 +360,7 @@ async def addidol(self, ctx, full_name, stage_name, group_id: int):
async def deleteidol(self, ctx, idol_id: int):
"""Deletes an idol [Format: %deleteidol (idol id)]"""
try:
idol_name = (await ex.get_member(idol_id))[1]
idol_name = (await ex.u_group_members.get_member(idol_id))[1]
await ex.conn.execute("DELETE FROM groupmembers.member WHERE id = $1", idol_id)
await ctx.send(f"{idol_name} ({idol_id}) deleted.")
except Exception as e:
Expand Down
Loading