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 branch to dev #22

Merged
merged 71 commits into from
Dec 28, 2020
Merged
Show file tree
Hide file tree
Changes from 45 commits
Commits
Show all changes
71 commits
Select commit Hold shift + click to select a range
a554ede
Starting to refactor Utility.py
MujyKun Dec 26, 2020
db3893f
Lastfm refactor
A-Phamfam Dec 26, 2020
5359cee
fixed issue with static method referencing Utility object
MujyKun Dec 26, 2020
a6954bc
Refactor patreon
A-Phamfam Dec 26, 2020
634a5ef
Refactor moderator
A-Phamfam Dec 26, 2020
77af4ee
Refactor customcommands
A-Phamfam Dec 26, 2020
e89d968
Refactor Biasgame
A-Phamfam Dec 26, 2020
766fde1
Refactor datadog
A-Phamfam Dec 26, 2020
f41da4d
Finished Refactoring Cache Util
MujyKun Dec 26, 2020
0aab956
Finished Refactoring Cache Util
MujyKun Dec 26, 2020
86419fd
Finished Refactoring Currency Util
MujyKun Dec 26, 2020
6719b24
Refactor weverse
A-Phamfam Dec 26, 2020
3fe154f
Refactor self assign roles
A-Phamfam Dec 26, 2020
7a192e7
Refactor reminder
A-Phamfam Dec 26, 2020
c6cdb5d
Refactor twitter
A-Phamfam Dec 26, 2020
5c0ceb2
Finished Refactoring Miscellaneous Util
MujyKun Dec 26, 2020
3113a1e
Refactor logging
A-Phamfam Dec 26, 2020
7c35245
Finished Refactoring BlackJack Util
MujyKun Dec 26, 2020
fe4fc01
Finished Refactoring Levels Util
MujyKun Dec 26, 2020
0c99d21
Refactor groupmembers
A-Phamfam Dec 26, 2020
1e77641
Merge pull request #3 from MujyKun/database
MujyKun Dec 26, 2020
de3c6a6
Merge pull request #4 from MujyKun/cache
MujyKun Dec 26, 2020
0822d64
Merge branch 'refactor' into currency
MujyKun Dec 26, 2020
14eb905
Merge pull request #5 from MujyKun/currency
MujyKun Dec 26, 2020
e794037
Merge branch 'refactor' into miscellaneous
MujyKun Dec 26, 2020
9f3a766
Merge pull request #6 from MujyKun/miscellaneous
MujyKun Dec 26, 2020
08e96f0
Merge branch 'refactor' into GroupMembers
MujyKun Dec 26, 2020
9712d44
Merge pull request #7 from MujyKun/GroupMembers
MujyKun Dec 26, 2020
4f37d0d
Merge branch 'refactor' into Logging
MujyKun Dec 26, 2020
7293ed2
Merge pull request #8 from MujyKun/Logging
MujyKun Dec 26, 2020
f3dfe03
Merge pull request #9 from MujyKun/Twitter
MujyKun Dec 26, 2020
694d6b2
Merge branch 'refactor' into Reminder
MujyKun Dec 26, 2020
d31cf24
Merge pull request #10 from MujyKun/Reminder
MujyKun Dec 26, 2020
3e52802
Merge branch 'refactor' into blackjack
MujyKun Dec 26, 2020
4945861
Merge pull request #11 from MujyKun/blackjack
MujyKun Dec 26, 2020
1961508
Merge pull request #12 from MujyKun/SelfAssignroles
MujyKun Dec 26, 2020
18f04c2
Merge branch 'refactor' into levels
MujyKun Dec 26, 2020
c80b818
Merge pull request #13 from MujyKun/levels
MujyKun Dec 26, 2020
11aac30
Merge branch 'refactor' into Weverse
MujyKun Dec 26, 2020
a20cb17
Merge pull request #14 from MujyKun/Weverse
MujyKun Dec 26, 2020
e714689
Merge branch 'refactor' into DataDog
MujyKun Dec 26, 2020
e00388c
Merge pull request #15 from MujyKun/DataDog
MujyKun Dec 26, 2020
f05b6dc
Merge pull request #16 from MujyKun/BiasGame
MujyKun Dec 26, 2020
6dc80d3
Merge branch 'refactor' into CustomCommands
MujyKun Dec 26, 2020
e68086c
Merge pull request #17 from MujyKun/CustomCommands
MujyKun Dec 26, 2020
4bd96a4
Merge branch 'refactor' into Moderator
MujyKun Dec 26, 2020
71659ab
Merge pull request #18 from MujyKun/Moderator
MujyKun Dec 26, 2020
60ce101
Merge branch 'refactor' into Patreon
MujyKun Dec 26, 2020
87a924f
Merge pull request #19 from MujyKun/Patreon
MujyKun Dec 26, 2020
db99ac6
Merge pull request #20 from MujyKun/Last_FM
MujyKun Dec 26, 2020
e5e64a5
Merge branch 'dev' into refactor
MujyKun Dec 26, 2020
8ae08ba
Need help fixing stuff
MujyKun Dec 26, 2020
2e5ebde
Refactor to ex.subclass
A-Phamfam Dec 26, 2020
cafa847
ex.subclasses
MujyKun Dec 26, 2020
ce0b1cf
Merge pull request #23 from MujyKun/refactor_p
MujyKun Dec 26, 2020
1547fd7
ex.subclasses
MujyKun Dec 26, 2020
4abdbb7
ex.subclasses
MujyKun Dec 26, 2020
1438d04
Changed so .get_cooldown_time() is being called from the proper subclass
A-Phamfam Dec 26, 2020
6fceb0d
Currently cleaning up warnings
MujyKun Dec 26, 2020
a9eb7aa
Merge branch 'refactor' of https://github.com/MujyKun/IreneBot into r…
MujyKun Dec 26, 2020
65e9e47
Added PyCharm inspection comments, shortened exceptions, and cleared …
MujyKun Dec 27, 2020
aa76edb
Added comments for acceptable Pycharm coding style violations
MujyKun Dec 27, 2020
cf5544e
Made all necessary methods static
MujyKun Dec 27, 2020
d4e7f2e
Added .gitkeep to folders and using .gitignore properly
MujyKun Dec 27, 2020
cbc764f
Removed unused module Cogs.
MujyKun Dec 27, 2020
3fdd556
Added a few comments in Utility
MujyKun Dec 27, 2020
4fd07b5
Added few comments
MujyKun Dec 28, 2020
12a0435
Added flask as a requirement
MujyKun Dec 28, 2020
c1e7c9e
Fixed references to methods that have been moved to util classes
A-Phamfam Dec 28, 2020
0d7c450
Fixed referencing issues with Utility and Utils
MujyKun Dec 28, 2020
0202b36
Merge branch 'refactor' of https://github.com/MujyKun/IreneBot into r…
MujyKun Dec 28, 2020
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
2,625 changes: 6 additions & 2,619 deletions Utility.py

Large diffs are not rendered by default.

8 changes: 4 additions & 4 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 All @@ -145,7 +145,7 @@ async def create_new_question(self):
{first_idol_group} ({first_idol.stage_name}) **VS** {second_idol_group} ({second_idol.stage_name})
"""
display_name = f"{first_idol.stage_name} VS {second_idol.stage_name}.png"
file_location = await ex.create_bias_game_image(first_idol.id, second_idol.id)
file_location = await ex.u_bias_game.create_bias_game_image(first_idol.id, second_idol.id)
image_file = discord.File(fp=file_location, filename=display_name)
msg = await self.channel.send(msg_body, file=image_file)
await msg.add_reaction(keys.previous_emoji) # left arrow by default
Expand Down
60 changes: 30 additions & 30 deletions module/BlackJack.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,33 +14,32 @@ async def blackjack(self, ctx, amount="0", versus="player"):
amount = ex.remove_commas(amount)
user_id = ctx.author.id
if versus != "bot":
if await ex.process_bj_game(ctx, amount, user_id):
await ex.add_bj_game(user_id, amount, ctx, "player")
if await ex.u_blackjack.process_bj_game(ctx, amount, user_id):
await ex.u_blackjack.add_bj_game(user_id, amount, ctx, "player")
else:
if await ex.process_bj_game(ctx, amount, user_id):
await ex.add_bj_game(user_id, amount, ctx, "bot")
game_id = await ex.get_game_by_player(user_id)
fake_bot_id = int(f"{ex.get_int_index(bot_id, 9)}{randint(1,999999999)}")
await ex.add_player_two(game_id, fake_bot_id, amount)
await ex.start_game(game_id)
if await ex.u_blackjack.process_bj_game(ctx, amount, user_id):
await ex.u_blackjack.add_bj_game(user_id, amount, ctx, "bot")
game_id = await ex.u_blackjack.get_game_by_player(user_id)
fake_bot_id = int(f"{ex.u_miscellaneous.get_int_index(bot_id, 9)}{randint(1,999999999)}")
await ex.u_blackjack.add_player_two(game_id, fake_bot_id, amount)
await ex.u_blackjack.start_game(game_id)
except Exception as e:
log.console(e)
pass

@commands.command(aliases=['jg'])
async def joingame(self, ctx, game_id=0, amount="0"):
"""Join a game [Format: %joingame (gameid) (bid)] [Aliases: jg]"""
try:
amount = ex.remove_commas(amount)
user_id = ctx.author.id
if await ex.process_bj_game(ctx, amount, user_id):
game = await ex.get_game(game_id)
if await ex.u_blackjack.process_bj_game(ctx, amount, user_id):
game = await ex.u_blackjack.get_game(game_id)
if game is None:
await ctx.send(f"> **{ctx.author}, {game_id} is not a valid game.**")
else:
if game[5] == ctx.channel.id: # Did not use already existing function due to incompatibility.
await ex.add_player_two(game_id, user_id, amount)
await ex.start_game(game_id)
await ex.u_blackjack.add_player_two(game_id, user_id, amount)
await ex.u_blackjack.start_game(game_id)
else:
await ctx.send(f"> **{ctx.author}, that game ({game_id}) is not available in this text channel.**")
except Exception as e:
Expand All @@ -50,11 +49,11 @@ async def joingame(self, ctx, game_id=0, amount="0"):
async def endgame(self, ctx):
"""End your current game [Format: %endgame] [Aliases: eg]"""
try:
game_id = await ex.get_game_by_player(ctx.author.id)
game_id = await ex.u_blackjack.get_game_by_player(ctx.author.id)
if game_id is None:
await ctx.send(f"> **{ctx.author}, you are not in a game.**")
else:
await ex.delete_game(game_id)
await ex.u_blackjack.delete_game(game_id)
await ctx.send(f"> **{ctx.author}, your game has been deleted.**")
except Exception as e:
log.console(e)
Expand Down Expand Up @@ -83,16 +82,16 @@ async def addcards(self, ctx):
async def hit(self, ctx):
"""Pick A Card [Format: %hit]"""
try:
game_id = await ex.get_game_by_player(ctx.author.id)
game_id = await ex.u_blackjack.get_game_by_player(ctx.author.id)
if not game_id:
await ctx.send(f"> **{ctx.author}, you are not in a game.**")
else:
if await ex.compare_channels(ctx.author.id, ctx.channel):
game = await ex.get_game(game_id)
if ex.check_if_bot(game[2]):
if await ex.get_player_total(game[2]) < 16:
await ex.add_card(game[2])
await ex.add_card(ctx.author.id)
game = await ex.u_blackjack.get_game(game_id)
if ex.u_blackjack.check_if_bot(game[2]):
if await ex.u_blackjack.get_player_total(game[2]) < 16:
await ex.u_blackjack.add_card(game[2])
await ex.u_blackjack.add_card(ctx.author.id)
except Exception as e:
log.console(e)

Expand All @@ -102,28 +101,28 @@ async def stand(self, ctx):
try:
check = False
user_id = ctx.author.id
game_id = await ex.get_game_by_player(user_id)
game_id = await ex.u_blackjack.get_game_by_player(user_id)
if game_id is None:
await ctx.send(f"> **{ctx.author}, you are not in a game.**")
else:
if await ex.compare_channels(user_id, ctx.channel):
# Do not inform other users that the player already stood by busting.
# Instead, just send the same message that they are standing every time this command is called.
await ex.set_player_stand(user_id)
game = await ex.get_game(game_id)
await ex.u_blackjack.set_player_stand(user_id)
game = await ex.u_blackjack.get_game(game_id)

if ex.check_if_bot(game[2]):
if ex.u_blackjack.check_if_bot(game[2]):
check = True
await ex.finish_game(game_id, ctx.channel)
await ex.u_blackjack.finish_game(game_id, ctx.channel)

if not check:
total_score = str(await ex.get_player_total(user_id))
total_score = str(await ex.u_blackjack.get_player_total(user_id))
if len(total_score) == 1:
total_score = '0' + total_score # this is to prevent being able to detect the number of digits by the spoiler
if not ex.check_if_bot(game[2]):
if not ex.u_blackjack.check_if_bot(game[2]):
await ctx.send(f"> **{ctx.author} finalized their deck with ||{total_score}|| points.**")
if await ex.check_game_over(game_id):
await ex.finish_game(game_id, ctx.channel)
if await ex.u_blackjack.check_game_over(game_id):
await ex.u_blackjack.finish_game(game_id, ctx.channel)
except Exception as e:
log.console(e)

Expand Down Expand Up @@ -151,3 +150,4 @@ async def rules(self, ctx):
await ctx.send(embed=embed)



32 changes: 16 additions & 16 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 @@ -129,8 +129,8 @@ async def mergeidol(self, ctx, original_idol_id: int, duplicate_idol_id: int):
# delete idol
await ex.conn.execute("DELETE FROM groupmembers.member WHERE id = $1", duplicate_idol.id)
# recreate cache
await ex.create_idol_cache()
await ex.create_group_cache()
await ex.u_cache.create_idol_cache()
await ex.u_cache.create_group_cache()
await ctx.send(f"> Merged {duplicate_idol_id} to {original_idol_id}.")

@commands.command()
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 All @@ -156,8 +156,8 @@ async def mergegroup(self, ctx, original_group_id: int, duplicate_group_id: int)
# delete group
await ex.conn.execute("DELETE FROM groupmembers.groups WHERE groupid = $1", duplicate_group.id)
# recreate cache
await ex.create_idol_cache()
await ex.create_group_cache()
await ex.u_cache.create_idol_cache()
await ex.u_cache.create_group_cache()
await ctx.send(f"> Merged {duplicate_group_id} to {original_group_id}.")

@commands.command()
Expand Down Expand Up @@ -257,7 +257,7 @@ async def deleteinteraction(self, ctx, *, url):
async def botban(self, ctx, *, user: discord.User):
"""Bans a user from Irene. [Format: %botban (user id)]"""
if not ex.check_if_mod(user.id, 1):
await ex.ban_user_from_bot(user.id)
await ex.u_miscellaneous.ban_user_from_bot(user.id)
await ctx.send(f"> **<@{user.id}> has been banned from using Irene.**")
else:
await ctx.send(f"> **<@{ctx.author.id}>, you cannot ban a bot mod.**")
Expand All @@ -267,7 +267,7 @@ async def botban(self, ctx, *, user: discord.User):
async def botunban(self, ctx, *, user: discord.User):
"""UnBans a user from Irene. [Format: %botunban (user id)]"""
user_id = user.id
await ex.unban_user_from_bot(user_id)
await ex.u_miscellaneous.unban_user_from_bot(user_id)
await ctx.send(f"> **If the user was banned, they are now unbanned.**")

@commands.command()
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