From 25abe5b125272d9d615d0f3aecb2196a760ac620 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 05:09:34 +0000 Subject: [PATCH 01/14] Improve logic in condition statements --- main.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/main.py b/main.py index 0b481a10..fa4916a4 100644 --- a/main.py +++ b/main.py @@ -137,10 +137,10 @@ async def on_message(ctx): if levels[str(ctx.author.id)]["xp"] >= xpreq: levels[str(ctx.author.id)]["xp"] = 0 levels[str(ctx.author.id)]["level"] += 1 - if settings.fetch_setting(ctx.author.id, "levelup_messages") == True: + if settings.fetch_setting(ctx.author.id, "levelup_messages") is True: await ctx.author.send(f"{ctx.author.mention}, you just ranked up to **level {levels[str(ctx.author.id)]['level']}**. Nice!") save() - if automod_config[str(ctx.guild.id)]["swear_filter"]["enabled"] == True: + if automod_config[str(ctx.guild.id)]["swear_filter"]["enabled"] is True: if automod_config[str(ctx.guild.id)]["swear_filter"]["keywords"]["use_default"] and any(x in ctx.content.lower() for x in automod_config[str(ctx.guild.id)]["swear_filter"]["keywords"]["default"]): await ctx.delete() await ctx.channel.send(f'{ctx.author.mention} watch your language.', delete_after=5) From 26080bb91697da28d4569580a93a0bee5ee7b327 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 05:10:23 +0000 Subject: [PATCH 02/14] Remove a disabled import --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index fa4916a4..f2011ce6 100644 --- a/main.py +++ b/main.py @@ -11,7 +11,6 @@ from math import floor from random import randint from framework.isobot import currency, colors, settings -# from framework.isobank import authorize, manager from discord import ApplicationContext, option from discord.ext import commands from discord.ext.commands import * From 10968ae19d105ac01ab69c1d8824a45a25d07e66 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:16:07 +0000 Subject: [PATCH 03/14] Fix variable naming style --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index f2011ce6..3e36c934 100644 --- a/main.py +++ b/main.py @@ -183,18 +183,18 @@ async def help(ctx: ApplicationContext, command: str = None): if commandsdb[command]['cooldown'] is not None: localembed.add_field(name="Cooldown", value=f"{str(datetime.timedelta(seconds=commandsdb[command]['cooldown']))}", inline=False) localembed.add_field(name="Usable By", value=commandsdb[command]['usable_by'], inline=False) if commandsdb[command]['args'] is not None: - r = "" - for x in commandsdb[command]['args']: r += f"`{x}` " - localembed.add_field(name="Arguments", value=r, inline=False) + args = "" + for arg in commandsdb[command]['args']: args += f"`{arg}` " + localembed.add_field(name="Arguments", value=args, inline=False) if commandsdb[command]['bugged'] is True: localembed.set_footer(text="⚠ This command might be bugged (experiencing issues), but will be fixed later.") if commandsdb[command]['disabled'] is True: localembed.set_footer(text="⚠ This command is currently disabled") await ctx.respond(embed=localembed) except KeyError: return await ctx.respond(embed=discord.Embed(description=f"No results found for {command}."), ephemeral=True) else: - r = "" - for x in commandsdb: - if commandsdb[x]["type"] != "DevTools": r += f"`/{x}`\n" - localembed = discord.Embed(title="Isobot Command Help", description=f"**Bot Commands:**\n{r}", color = color) + commands_list = "" + for _command in commandsdb: + if commandsdb[_command]["type"] != "DevTools": commands_list += f"`/{_command}`\n" + localembed = discord.Embed(title="Isobot Command Help", description=f"**Bot Commands:**\n{commands_list}", color = color) await ctx.author.send(embed=localembed) await ctx.respond("Check your direct messages.", ephemeral=True) From a20c286cc81d95e3acec9eb0249a1b97af85d8c3 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:17:27 +0000 Subject: [PATCH 04/14] Remove extra newlines between functions --- main.py | 3 --- 1 file changed, 3 deletions(-) diff --git a/main.py b/main.py index 3e36c934..0fdd8f57 100644 --- a/main.py +++ b/main.py @@ -228,7 +228,6 @@ async def load(ctx: ApplicationContext, cog: str): ) ) - @cogs.command( name="disable", description="Disables a cog." @@ -248,8 +247,6 @@ async def disable(ctx: ApplicationContext, cog: str): ) ) - - @cogs.command( name="reload", description="Reloads a cog." From 15b9c18f11d814c1f6f4311207ca7b5aed903dc7 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:27:51 +0000 Subject: [PATCH 05/14] Add newlines wherever necessary --- main.py | 63 +++++++++++++++++++++++++++++++++++++++++++-------------- 1 file changed, 48 insertions(+), 15 deletions(-) diff --git a/main.py b/main.py index 0fdd8f57..fcfd9dcd 100644 --- a/main.py +++ b/main.py @@ -51,7 +51,8 @@ def save(): time.sleep(0.5) open('logs/currency.log', 'x', encoding="utf-8") logger.info("Created currency log", nolog=True) - except Exception as e: logger.error(f"Failed to make log file: {e}", nolog=True) + except Exception as e: + logger.error(f"Failed to make log file: {e}", nolog=True) #Framework Module Loader colors = colors.Colors() @@ -96,8 +97,10 @@ async def on_message(ctx): create_isocoin_key(ctx.author.id) new_userdat(ctx.author.id) settings.generate(ctx.author.id) - if str(ctx.author.id) not in items: items[str(ctx.author.id)] = {} - if str(ctx.author.id) not in levels: levels[str(ctx.author.id)] = {"xp": 0, "level": 0} + if str(ctx.author.id) not in items: + items[str(ctx.author.id)] = {} + if str(ctx.author.id) not in levels: + levels[str(ctx.author.id)] = {"xp": 0, "level": 0} if str(ctx.guild.id) not in automod_config: automod_config[str(ctx.guild.id)] = { "swear_filter": { @@ -178,18 +181,29 @@ async def on_application_command_error(ctx: ApplicationContext, error: discord.D async def help(ctx: ApplicationContext, command: str = None): if command is not None: try: - localembed = discord.Embed(title=f"{commandsdb[command]['name']} Command (/{command})", description=commandsdb[command]['description'], color=color) + localembed = discord.Embed( + title=f"{commandsdb[command]['name']} Command (/{command})", + description=commandsdb[command]['description'], + color=color + ) localembed.add_field(name="Command Type", value=commandsdb[command]['type'], inline=False) - if commandsdb[command]['cooldown'] is not None: localembed.add_field(name="Cooldown", value=f"{str(datetime.timedelta(seconds=commandsdb[command]['cooldown']))}", inline=False) + if commandsdb[command]['cooldown'] is not None: + localembed.add_field(name="Cooldown", value=f"{str(datetime.timedelta(seconds=commandsdb[command]['cooldown']))}", inline=False) localembed.add_field(name="Usable By", value=commandsdb[command]['usable_by'], inline=False) if commandsdb[command]['args'] is not None: args = "" for arg in commandsdb[command]['args']: args += f"`{arg}` " localembed.add_field(name="Arguments", value=args, inline=False) - if commandsdb[command]['bugged'] is True: localembed.set_footer(text="⚠ This command might be bugged (experiencing issues), but will be fixed later.") - if commandsdb[command]['disabled'] is True: localembed.set_footer(text="⚠ This command is currently disabled") + if commandsdb[command]['bugged'] is True: + localembed.set_footer(text="⚠ This command might be bugged (experiencing issues), but will be fixed later.") + if commandsdb[command]['disabled'] is True: + localembed.set_footer(text="⚠ This command is currently disabled") await ctx.respond(embed=localembed) - except KeyError: return await ctx.respond(embed=discord.Embed(description=f"No results found for {command}."), ephemeral=True) + except KeyError: + return await ctx.respond( + embed=discord.Embed(description=f"No results found for {command}."), + ephemeral=True + ) else: commands_list = "" for _command in commandsdb: @@ -207,10 +221,16 @@ async def help(ctx: ApplicationContext, command: str = None): ) @option(name="cog", description="What cog do you want to load?", type=str) async def load(ctx: ApplicationContext, cog: str): - if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) + if ctx.author.id != 738290097170153472: + return await ctx.respond("You can't use this command!", ephemeral=True) try: client.load_extension(f"cogs.{cog}") - await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully loaded.", color=discord.Color.green())) + await ctx.respond( + embed=discord.Embed( + description=f"{cog} cog successfully loaded.", + color=discord.Color.green() + ) + ) except discord.errors.ExtensionNotFound: return await ctx.respond( embed=discord.Embed( @@ -234,10 +254,16 @@ async def load(ctx: ApplicationContext, cog: str): ) @option(name="cog", description="What cog do you want to disable?", type=str) async def disable(ctx: ApplicationContext, cog: str): - if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) + if ctx.author.id != 738290097170153472: + return await ctx.respond("You can't use this command!", ephemeral=True) try: client.unload_extension(f"cogs.{cog}") - await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully disabled.", color=discord.Color.green())) + await ctx.respond( + embed=discord.Embed( + description=f"{cog} cog successfully disabled.", + color=discord.Color.green() + ) + ) except discord.errors.ExtensionNotFound: return await ctx.respond( embed=discord.Embed( @@ -253,10 +279,16 @@ async def disable(ctx: ApplicationContext, cog: str): ) @option(name="cog", description="What cog do you want to reload?", type=str) async def reload(ctx: ApplicationContext, cog: str): - if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) + if ctx.author.id != 738290097170153472: + return await ctx.respond("You can't use this command!", ephemeral=True) try: client.reload_extension(f"cogs.{cog}") - await ctx.respond(embed=discord.Embed(description=f"{cog} cog successfully reloaded.", color=discord.Color.green())) + await ctx.respond( + embed=discord.Embed( + description=f"{cog} cog successfully reloaded.", + color=discord.Color.green() + ) + ) except discord.errors.ExtensionNotFound: return await ctx.respond( embed=discord.Embed( @@ -275,7 +307,8 @@ async def reload(ctx: ApplicationContext, cog: str): ) @option(name="enabled", description="Do you want this setting enabled?", type=bool) async def levelup_messages(ctx: ApplicationContext, enabled: bool): - if settings.fetch_setting(ctx.author.id, "levelup_messages") == enabled: return await ctx.respond("This is already done.", ephemeral=True) + if settings.fetch_setting(ctx.author.id, "levelup_messages") == enabled: + return await ctx.respond("This is already done.", ephemeral=True) settings.edit_setting(ctx.author.id, "levelup_messages", enabled) localembed = discord.Embed( description="Setting successfully updated.", From 4ef6a9afa32e9509241d6ff542781c52a3e2d074 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:29:52 +0000 Subject: [PATCH 06/14] Remove trailing whitespaces --- main.py | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/main.py b/main.py index fcfd9dcd..d00ad449 100644 --- a/main.py +++ b/main.py @@ -51,7 +51,7 @@ def save(): time.sleep(0.5) open('logs/currency.log', 'x', encoding="utf-8") logger.info("Created currency log", nolog=True) - except Exception as e: + except Exception as e: logger.error(f"Failed to make log file: {e}", nolog=True) #Framework Module Loader @@ -97,9 +97,9 @@ async def on_message(ctx): create_isocoin_key(ctx.author.id) new_userdat(ctx.author.id) settings.generate(ctx.author.id) - if str(ctx.author.id) not in items: + if str(ctx.author.id) not in items: items[str(ctx.author.id)] = {} - if str(ctx.author.id) not in levels: + if str(ctx.author.id) not in levels: levels[str(ctx.author.id)] = {"xp": 0, "level": 0} if str(ctx.guild.id) not in automod_config: automod_config[str(ctx.guild.id)] = { @@ -199,7 +199,7 @@ async def help(ctx: ApplicationContext, command: str = None): if commandsdb[command]['disabled'] is True: localembed.set_footer(text="⚠ This command is currently disabled") await ctx.respond(embed=localembed) - except KeyError: + except KeyError: return await ctx.respond( embed=discord.Embed(description=f"No results found for {command}."), ephemeral=True @@ -221,13 +221,13 @@ async def help(ctx: ApplicationContext, command: str = None): ) @option(name="cog", description="What cog do you want to load?", type=str) async def load(ctx: ApplicationContext, cog: str): - if ctx.author.id != 738290097170153472: + if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) try: client.load_extension(f"cogs.{cog}") await ctx.respond( embed=discord.Embed( - description=f"{cog} cog successfully loaded.", + description=f"{cog} cog successfully loaded.", color=discord.Color.green() ) ) @@ -285,7 +285,7 @@ async def reload(ctx: ApplicationContext, cog: str): client.reload_extension(f"cogs.{cog}") await ctx.respond( embed=discord.Embed( - description=f"{cog} cog successfully reloaded.", + description=f"{cog} cog successfully reloaded.", color=discord.Color.green() ) ) From deae347a13b8a95e6ea677e71e318d8647fb1902 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:33:30 +0000 Subject: [PATCH 07/14] Reduce `Exception` handling range when making log files --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index d00ad449..81b31a66 100644 --- a/main.py +++ b/main.py @@ -51,7 +51,7 @@ def save(): time.sleep(0.5) open('logs/currency.log', 'x', encoding="utf-8") logger.info("Created currency log", nolog=True) - except Exception as e: + except IOError as e: logger.error(f"Failed to make log file: {e}", nolog=True) #Framework Module Loader From a945a1b0b2749056008f316ebf55b121b598c1f2 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:37:11 +0000 Subject: [PATCH 08/14] Reduce `Exception` range when initially loading cog --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 81b31a66..6cb21680 100644 --- a/main.py +++ b/main.py @@ -339,7 +339,7 @@ async def levelup_messages(ctx: ApplicationContext, enabled: bool): print(f"[main/Cogs] Loading isobot Cog ({i}/{len(active_cogs)})") i += 1 try: client.load_extension(f"cogs.{x}") - except Exception as e: + except discord.errors.ExtensionFailed as e: cog_errors += 1 print(f"[main/Cogs] {colors.red}ERROR: Cog '{x}' failed to load: {e}{colors.end}") if cog_errors == 0: print(f"[main/Cogs] {colors.green}All cogs successfully loaded.{colors.end}") From 1914472d130b9a39c436e1395fe30416fbb99528 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:44:56 +0000 Subject: [PATCH 09/14] Add missing docstrings for functions --- main.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/main.py b/main.py index 6cb21680..6643c317 100644 --- a/main.py +++ b/main.py @@ -35,6 +35,7 @@ #Pre-Initialization Commands def save(): + """Dumps all cached data to the local databases.""" with open('database/items.json', 'w+', encoding="utf-8") as f: json.dump(items, f, indent=4) with open('database/presence.json', 'w+', encoding="utf-8") as f: json.dump(presence, f, indent=4) with open('database/levels.json', 'w+', encoding="utf-8") as f: json.dump(levels, f, indent=4) @@ -76,6 +77,7 @@ def save(): #Events @client.event async def on_ready(): + """This event is fired when the bot client is ready""" print(""" Isobot Copyright (C) 2022 PyBotDevs/NKA This program comes with ABSOLUTELY NO WARRANTY. @@ -92,6 +94,7 @@ async def on_ready(): @client.event async def on_message(ctx): + """This event is fired whenever a message is sent (in a readable channel)""" currency.new_wallet(ctx.author.id) currency.new_bank(ctx.author.id) create_isocoin_key(ctx.author.id) @@ -153,6 +156,7 @@ async def on_message(ctx): #Error handler @client.event async def on_application_command_error(ctx: ApplicationContext, error: discord.DiscordException): + """An event handler to handle command exceptions when things go wrong.""" current_time = datetime.time().strftime("%H:%M:%S") if isinstance(error, commands.CommandOnCooldown): await ctx.respond(f":stopwatch: Not now! Please try after **{str(datetime.timedelta(seconds=int(round(error.retry_after))))}**") @@ -179,6 +183,7 @@ async def on_application_command_error(ctx: ApplicationContext, error: discord.D ) @option(name="command", description="Which command do you need help with?", type=str, default=None) async def help(ctx: ApplicationContext, command: str = None): + """Gives you help with a specific command, or shows a list of all commands""" if command is not None: try: localembed = discord.Embed( @@ -221,6 +226,7 @@ async def help(ctx: ApplicationContext, command: str = None): ) @option(name="cog", description="What cog do you want to load?", type=str) async def load(ctx: ApplicationContext, cog: str): + """Loads a cog.""" if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) try: @@ -254,6 +260,7 @@ async def load(ctx: ApplicationContext, cog: str): ) @option(name="cog", description="What cog do you want to disable?", type=str) async def disable(ctx: ApplicationContext, cog: str): + """Disables a cog.""" if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) try: @@ -279,6 +286,7 @@ async def disable(ctx: ApplicationContext, cog: str): ) @option(name="cog", description="What cog do you want to reload?", type=str) async def reload(ctx: ApplicationContext, cog: str): + """Reloads a cog.""" if ctx.author.id != 738290097170153472: return await ctx.respond("You can't use this command!", ephemeral=True) try: @@ -307,6 +315,7 @@ async def reload(ctx: ApplicationContext, cog: str): ) @option(name="enabled", description="Do you want this setting enabled?", type=bool) async def levelup_messages(ctx: ApplicationContext, enabled: bool): + """Configure whether you want to be notified for level ups or not.""" if settings.fetch_setting(ctx.author.id, "levelup_messages") == enabled: return await ctx.respond("This is already done.", ephemeral=True) settings.edit_setting(ctx.author.id, "levelup_messages", enabled) From c47f1db8fd39262d2192167a2978f6459a832a5d Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:48:08 +0000 Subject: [PATCH 10/14] Rename internal redefined `help()` command --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6643c317..f685d299 100644 --- a/main.py +++ b/main.py @@ -182,7 +182,7 @@ async def on_application_command_error(ctx: ApplicationContext, error: discord.D description="Gives you help with a specific command, or shows a list of all commands" ) @option(name="command", description="Which command do you need help with?", type=str, default=None) -async def help(ctx: ApplicationContext, command: str = None): +async def _help(ctx: ApplicationContext, command: str = None): """Gives you help with a specific command, or shows a list of all commands""" if command is not None: try: From 4ce0b4c911b27b1eb872ff588415499606dc9dc6 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:48:52 +0000 Subject: [PATCH 11/14] Undo the last commit (based) --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index f685d299..6643c317 100644 --- a/main.py +++ b/main.py @@ -182,7 +182,7 @@ async def on_application_command_error(ctx: ApplicationContext, error: discord.D description="Gives you help with a specific command, or shows a list of all commands" ) @option(name="command", description="Which command do you need help with?", type=str, default=None) -async def _help(ctx: ApplicationContext, command: str = None): +async def help(ctx: ApplicationContext, command: str = None): """Gives you help with a specific command, or shows a list of all commands""" if command is not None: try: From 2c88a6f10220ea9e161e3d8078ec9f2c039c5a56 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 08:51:39 +0000 Subject: [PATCH 12/14] Remove redundant `discord.commands.ext` wildcard import --- main.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/main.py b/main.py index 6643c317..9ddc4e65 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,7 @@ from framework.isobot import currency, colors, settings from discord import ApplicationContext, option from discord.ext import commands -from discord.ext.commands import * +#from discord.ext.commands import * from cogs.economy import new_userdat from cogs.isocoin import create_isocoin_key From 5f7ce2e240ec9bfd95ce185da41269982d52e28b Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:02:42 +0000 Subject: [PATCH 13/14] Remove disabled `discord.commands.ext.*` import --- main.py | 1 - 1 file changed, 1 deletion(-) diff --git a/main.py b/main.py index 9ddc4e65..1d265707 100644 --- a/main.py +++ b/main.py @@ -13,7 +13,6 @@ from framework.isobot import currency, colors, settings from discord import ApplicationContext, option from discord.ext import commands -#from discord.ext.commands import * from cogs.economy import new_userdat from cogs.isocoin import create_isocoin_key From 5a549c771085329bee5e5a556c5fa83ee3d497a2 Mon Sep 17 00:00:00 2001 From: Sabi <120003982+cyanogus@users.noreply.github.com> Date: Thu, 6 Jul 2023 09:11:28 +0000 Subject: [PATCH 14/14] Improve variable naming scheme --- main.py | 18 +++++++++--------- 1 file changed, 9 insertions(+), 9 deletions(-) diff --git a/main.py b/main.py index 1d265707..ab72c7e9 100644 --- a/main.py +++ b/main.py @@ -35,10 +35,10 @@ #Pre-Initialization Commands def save(): """Dumps all cached data to the local databases.""" - with open('database/items.json', 'w+', encoding="utf-8") as f: json.dump(items, f, indent=4) - with open('database/presence.json', 'w+', encoding="utf-8") as f: json.dump(presence, f, indent=4) - with open('database/levels.json', 'w+', encoding="utf-8") as f: json.dump(levels, f, indent=4) - with open('database/automod.json', 'w+', encoding="utf-8") as f: json.dump(automod_config, f, indent=4) + with open('database/items.json', 'w+', encoding="utf-8") as e: json.dump(items, e, indent=4) + with open('database/presence.json', 'w+', encoding="utf-8") as e: json.dump(presence, e, indent=4) + with open('database/levels.json', 'w+', encoding="utf-8") as e: json.dump(levels, e, indent=4) + with open('database/automod.json', 'w+', encoding="utf-8") as e: json.dump(automod_config, e, indent=4) if not os.path.isdir("logs"): os.mkdir('logs') @@ -120,12 +120,12 @@ async def on_message(ctx): save() uList = list() if str(ctx.guild.id) in presence: - for x in presence[str(ctx.guild.id)].keys(): uList.append(x) + for userid in presence[str(ctx.guild.id)].keys(): uList.append(userid) else: pass - for i in uList: - if i in ctx.content and not ctx.author.bot: - fetch_user = client.get_user(id(i)) - await ctx.channel.send(f"{fetch_user.display_name} went AFK : {presence[str(ctx.guild.id)][str(i)]['response']}") + for user in uList: + if user in ctx.content and not ctx.author.bot: + fetch_user = client.get_user(id(user)) + await ctx.channel.send(f"{fetch_user.display_name} went AFK : {presence[str(ctx.guild.id)][str(user)]['response']}") if str(ctx.guild.id) in presence and str(ctx.author.id) in presence[str(ctx.guild.id)]: del presence[str(ctx.guild.id)][str(ctx.author.id)] save()