From 6709d688a73451fffeb24117a7568c433c4e221c Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Fri, 15 Nov 2024 19:57:52 +0530 Subject: [PATCH 1/2] Convert some lists to tuples in main code --- main.py | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/main.py b/main.py index 9202b0d..b0f8d79 100644 --- a/main.py +++ b/main.py @@ -31,7 +31,7 @@ def initial_setup(): """Runs the initial setup for isobot's directories.\nThis creates missing directories, new log files, as well as new databases for any missing `.json` database files.""" # Create required client directories try: - paths = ["database", "database/isobank", "config", "logs", "themes"] + paths = ("database", "database/isobank", "config", "logs", "themes") for p in paths: if not os.path.isdir(p): logger.warn(f"'{p}' directory appears to be missing. Created new directory for '{p}'.", module="main/Setup", nolog=True) @@ -41,7 +41,7 @@ def initial_setup(): # Generating database files try: - databases = [ + databases = ( "automod", "currency", "isocard", @@ -56,7 +56,7 @@ def initial_setup(): "embeds", "isobank/accounts", "isobank/auth" - ] + ) for f in databases: if not os.path.isfile(f"database/{f}.json"): logger.warn(f"[main/Setup] '{f}.json' was not found in database directory. Creating new database...", module="main/Setup", nolog=True) @@ -578,7 +578,7 @@ async def credits(ctx: ApplicationContext): await ctx.respond(embed=localembed) # Initialization -active_cogs = [ +active_cogs = ( "economy", "maths", "reddit", @@ -594,7 +594,7 @@ async def credits(ctx: ApplicationContext): # "osu", Disabled due to ossapi library metadata issues. (will probably remove osu cog anyway, because cog code is outdated with ossapi library) "weather", "isocard" -] +) i = 1 cog_errors = 0 for x in active_cogs: From 8d46289498e4c6d5334582b482ec538792caa4ad Mon Sep 17 00:00:00 2001 From: snipe <72265661+notsniped@users.noreply.github.com> Date: Sat, 16 Nov 2024 18:53:00 +0530 Subject: [PATCH 2/2] Convert more lists into tuples because yes --- cogs/economy.py | 20 ++++++++++---------- cogs/fun.py | 2 +- 2 files changed, 11 insertions(+), 11 deletions(-) diff --git a/cogs/economy.py b/cogs/economy.py index 123b896..e408800 100644 --- a/cogs/economy.py +++ b/cogs/economy.py @@ -23,7 +23,7 @@ shop_data = ShopData("config/shop.json") all_item_ids = shop_data.get_item_ids() shopitem = shop_data.get_raw_data() -jobs = [ +jobs = ( "Discord mod", "YouTuber", "Streamer", @@ -31,7 +31,7 @@ "Scientist", "Engineer", "Doctor" -] +) # Commands class Economy(commands.Cog): @@ -99,7 +99,7 @@ async def openlootbox(self, ctx: ApplicationContext, lootbox:str, amount:int): ) @commands.cooldown(1, 15, commands.BucketType.user) async def beg(self, ctx: ApplicationContext): - names = [ + names = ( "A random person", "Your friend", "Your boss", @@ -126,8 +126,8 @@ async def beg(self, ctx: ApplicationContext): "Your maths teacher", "Galaxy", "Taylor Swift" - ] - fail_responses = [ + ) + fail_responses = ( "Maybe another day.", "Hell nah.", "Sorry I don't have any cash on me.", @@ -140,7 +140,7 @@ async def beg(self, ctx: ApplicationContext): "I think I know what you're gonna do with that money.", "Debloat notsniped's code and he will probably give you money.", "If you win a chess match against Xyren she will give you money." - ] + ) if (randint(1, 100) >= 50): x = randint(10, 100) currency.add(ctx.author.id, x) @@ -220,7 +220,7 @@ async def bankrob(self, ctx: ApplicationContext, user:discord.User): @commands.cooldown(1, 30, commands.BucketType.user) async def hunt(self, ctx: ApplicationContext): if items.fetch_item_count(ctx.author.id, "rifle") == 0: return await ctx.respond("I'd hate to see you hunt with your bare hands. Please buy a hunting rifle from the shop. ||/buy rifle||") - loot = ['rock', 'ant', 'skunk', 'boar', 'deer', 'dragon', 'nothing', 'died'] + loot = ('rock', 'ant', 'skunk', 'boar', 'deer', 'dragon', 'nothing', 'died') choice = random.choice(loot) if choice != "nothing" and choice != "died": items.add_item(ctx.author.id, choice) @@ -237,7 +237,7 @@ async def hunt(self, ctx: ApplicationContext): @commands.cooldown(1, 45, commands.BucketType.user) async def fish(self, ctx: ApplicationContext): if items.fetch_item_count(ctx.author.id, "fishingpole") == 0: return await ctx.respond("I don't think you can fish with your bare hands... or you can just put yo hands in the water bro **giga chad moment**\nAnyway it's just better to buy a fishing pole from the shop. ||/buy fishingpole||") - loot = ['shrimp', 'fish', 'rare fish', 'exotic fish', 'jellyfish', 'shark', 'nothing'] + loot = ('shrimp', 'fish', 'rare fish', 'exotic fish', 'jellyfish', 'shark', 'nothing') choice = random.choice(loot) if choice != "nothing": items.add_item(ctx.author.id, choice) @@ -251,7 +251,7 @@ async def fish(self, ctx: ApplicationContext): @commands.cooldown(1, 45, commands.BucketType.user) async def dig(self, ctx: ApplicationContext): if items.fetch_item_count(ctx.author.id, "shovel") == 0: return await ctx.respond("You're too good to have to dig with your bare hands..... at least I hope so. Please buy a shovel from the shop. ||/buy shovel||") - loot = [ + loot = ( 'coins', 'shovel', 'ant', @@ -262,7 +262,7 @@ async def dig(self, ctx: ApplicationContext): 'rare lootbox', 'nothing', 'died', - ] + ) choice = random.choice(loot) if (choice == "coins"): currency.add(ctx.author.id, random.randint('1000', '5000')) diff --git a/cogs/fun.py b/cogs/fun.py index bf92cf6..cc4b1f2 100644 --- a/cogs/fun.py +++ b/cogs/fun.py @@ -52,7 +52,7 @@ async def owoify(self, ctx: ApplicationContext, text: str): text = text.replace("the", "da") text = text.replace("you", "u") text = text.replace("your", "ur") - text += random.choice([" uwu", " owo", " UwU", " OwO", " XDDD", " :D", " ;-;", " <3", " ^-^", " >-<"]) + text += random.choice((" uwu", " owo", " UwU", " OwO", " XDDD", " :D", " ;-;", " <3", " ^-^", " >-<")) await ctx.respond(text) @commands.slash_command(