Skip to content

Commit

Permalink
Format Files and Minor Updates
Browse files Browse the repository at this point in the history
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.
  • Loading branch information
infinotiver committed Apr 7, 2024
1 parent 3659530 commit 027716a
Show file tree
Hide file tree
Showing 7 changed files with 32 additions and 20 deletions.
26 changes: 16 additions & 10 deletions cogs/academia_resources.py
Original file line number Diff line number Diff line change
Expand Up @@ -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)
Expand All @@ -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):
Expand All @@ -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(
Expand Down Expand Up @@ -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,
Expand All @@ -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)
Expand Down
3 changes: 2 additions & 1 deletion cogs/arithmetic.py
Original file line number Diff line number Diff line change
Expand Up @@ -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=[
Expand Down
1 change: 1 addition & 0 deletions cogs/atlas.py
Original file line number Diff line number Diff line change
Expand Up @@ -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(
Expand Down
6 changes: 3 additions & 3 deletions cogs/leveling.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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(
Expand Down
2 changes: 1 addition & 1 deletion discord.py
Submodule discord.py updated from 425edd to 6ecd37
12 changes: 8 additions & 4 deletions keeplive.py
Original file line number Diff line number Diff line change
@@ -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()
t.start()
2 changes: 1 addition & 1 deletion utils/automod.py
Original file line number Diff line number Diff line change
Expand Up @@ -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
}

Expand Down

0 comments on commit 027716a

Please sign in to comment.