From 027716a102d85e117ae43270bac1c013849ba69b Mon Sep 17 00:00:00 2001 From: prakarsh17 <88645086+infinotiver@users.noreply.github.com> Date: Sun, 7 Apr 2024 18:07:47 +0530 Subject: [PATCH] Format Files and Minor Updates 1. `cogs/academia_resources.py`: - Updated the `Resource` class with a new command `submit` for submitting academic resources. - Added choices for resource types. - Modified the `get_choices` function to filter choices based on the current input. - Updated the `submit` function to store resource details in the database and send a confirmation message. 2. `cogs/arithmetic.py`: - Added a description to the `simple-functions` command. 3. `cogs/atlas.py`: - Added a TODO comment for correcting the playing game order and lists. 4. `cogs/leveling.py`: - Updated the embed message with the user's avatar. - Modified the `lb` function to fetch the latest leveling details. 5. `discord.py`: - Updated the subproject commit hash. 6. `keeplive.py`: - Added a space for readability. 7. `utils/automod.py`: - Fixed a minor formatting issue in the `text_moderation` function. --- cogs/academia_resources.py | 26 ++++++++++++++++---------- cogs/arithmetic.py | 3 ++- cogs/atlas.py | 1 + cogs/leveling.py | 6 +++--- discord.py | 2 +- keeplive.py | 12 ++++++++---- utils/automod.py | 2 +- 7 files changed, 32 insertions(+), 20 deletions(-) diff --git a/cogs/academia_resources.py b/cogs/academia_resources.py index 6a712155e..b5d4c5625 100644 --- a/cogs/academia_resources.py +++ b/cogs/academia_resources.py @@ -8,6 +8,7 @@ import typing import utils.functions as funcs from utils.functions import dembed + # Database connection (replace with your credentials) mongo_url = os.environ["mongodb"] cluster = motor.motor_asyncio.AsyncIOMotorClient(mongo_url) @@ -31,14 +32,12 @@ async def resource_name_autocompletion( self, interaction: discord.Interaction, current: str ) -> typing.List[app_commands.Choice[str]]: data = [] - queries_cursor = resources_collection.find( - {} - ) + queries_cursor = resources_collection.find({}) async for ( query ) in queries_cursor: # Iterate over the cursor to construct the choices title_words = query["name"].split() - title= query["name"] + title = query["name"] id = query["id"] for word in title_words: if current.lower() in map(str.lower, title_words): @@ -47,15 +46,20 @@ async def resource_name_autocompletion( ) break return data + @group.command(name="submit") @app_commands.choices( resource_type=[ app_commands.Choice(name="Class Notes", value="class_notes"), app_commands.Choice(name="Revision Sheets", value="revision_sheets"), - app_commands.Choice(name="Old Periodic/Weekly Assessments",value="assessments"), - app_commands.Choice(name="Previous Year Final Exam Question Papers",value="question_paper"), - app_commands.Choice(name="Online Resources",value="online_resources"), - app_commands.Choice(name="Others",value="others") + app_commands.Choice( + name="Old Periodic/Weekly Assessments", value="assessments" + ), + app_commands.Choice( + name="Previous Year Final Exam Question Papers", value="question_paper" + ), + app_commands.Choice(name="Online Resources", value="online_resources"), + app_commands.Choice(name="Others", value="others"), ] ) async def submit( @@ -86,7 +90,7 @@ async def submit( id = str(await resources_collection.count_documents({}) + 1) # Store resource details in database new_resource = { - "id":id, + "id": id, "type": resource_type.value, "name": name, "description": description, @@ -101,7 +105,9 @@ async def submit( # Send confirmation message await ctx.response.send_message( - embed=dembed(description=f"Thank you, {ctx.user.mention}! Your resource '**{name}**' (ID : `{id}` ) has been submitted for review.") + embed=dembed( + description=f"Thank you, {ctx.user.mention}! Your resource '**{name}**' (ID : `{id}` ) has been submitted for review." + ) ) # Notify reviewers (optional) diff --git a/cogs/arithmetic.py b/cogs/arithmetic.py index 03e4b9ca9..de9166ef8 100644 --- a/cogs/arithmetic.py +++ b/cogs/arithmetic.py @@ -205,7 +205,8 @@ async def triviafact(self, ctx): ) @group.command( - name="simple-functions", description="Perform various simple mathematical functions " + name="simple-functions", + description="Perform various simple mathematical functions ", ) @app_commands.choices( func=[ diff --git a/cogs/atlas.py b/cogs/atlas.py index 5212fe79d..0c862ade5 100644 --- a/cogs/atlas.py +++ b/cogs/atlas.py @@ -116,6 +116,7 @@ async def enter(self, ctx): @atlas.command(name="game-start", description="Start a game of ATLAS") async def start(self, ctx): + # TODO correct playing game order, and lists. Don't edit previous msg await ctx.response.defer() if str(ctx.guild.id) not in self.games: return await ctx.followup.send( diff --git a/cogs/leveling.py b/cogs/leveling.py index 46c30b96e..16a3a76c1 100644 --- a/cogs/leveling.py +++ b/cogs/leveling.py @@ -108,9 +108,9 @@ async def rank( f"XP: **{xp}/{int(200 * ((1 / 2) * lvl))}**\n" f"Global Rank: **{rank}**\n" f"Level: **{lvl}**\n" - f"Progress Bar : {progress_bar}\n" + f"Progress Bar : **{progress_bar}**\n" ) - embed = dembed(description=message) + embed = dembed(description=message, thumbnail=ctx.user.avatar.url) await ctx.followup.send( embed=embed, # file=discord.File(image, filename="rank.png") @@ -120,7 +120,7 @@ async def rank( async def lb(self, ctx): await ctx.response.send_message( embed=dembed(description="Wait till I fetch the latest details") - ) + ) rankings = levelling.find().sort("xp", -1) i = 1 embed = dembed( diff --git a/discord.py b/discord.py index 425edd2e1..6ecd376b5 160000 --- a/discord.py +++ b/discord.py @@ -1 +1 @@ -Subproject commit 425edd2e10b9be3d7799c0df0cd1d43a1a34654e +Subproject commit 6ecd376b5155dd2afb6ecdc14b58631854d64c2c diff --git a/keeplive.py b/keeplive.py index b0b923578..8afb36a16 100644 --- a/keeplive.py +++ b/keeplive.py @@ -1,14 +1,18 @@ from flask import Flask from threading import Thread -app = Flask('') +app = Flask("") -@app.route('/') + +@app.route("/") def home(): return "Accumen alive alright" + + def run(): - app.run(host='0.0.0.0', port=8080) + app.run(host="0.0.0.0", port=8080) + def keep_alive(): t = Thread(target=run) - t.start() \ No newline at end of file + t.start() diff --git a/utils/automod.py b/utils/automod.py index a1f28e155..9622b22ac 100644 --- a/utils/automod.py +++ b/utils/automod.py @@ -23,7 +23,7 @@ def text_moderation(text): "threat": 0.8, "offensive": 0.95, "erotic": 0.5, - "indecent": 1, # Practically impossible + "indecent": 1.0, # Practically impossible "spam": 0.95, # Higher threshold for spam to avoid false positives }