Skip to content

Commit

Permalink
documentation for commands;readme
Browse files Browse the repository at this point in the history
  • Loading branch information
vishalnandagopal committed Jan 17, 2024
1 parent 724ba0a commit 34cfd1d
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 14 deletions.
7 changes: 3 additions & 4 deletions .gitignore
Original file line number Diff line number Diff line change
@@ -1,3 +1,6 @@
# Don't ignore these files
!points.json

testing.py
Pipfile
Pipfile.lock
Expand All @@ -11,10 +14,6 @@ Pipfile.lock

members.txt

# Don't ignore these files
!points.json


__pycache__/
.mypy_cache/
.vscode/
Expand Down
31 changes: 30 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,36 @@ ROOT_USER=handydandyrandy

There are no data types in ENV, have to convert everything from str to required type. Types are just mentioned to give approx idea of what kind of values are expected for each key.

### 2. Run using docker
### 2. points.json

Number of points for each task. Uses hardcoded values if file absent.

```json
{
"pull request": 20,
"info": 40,
"blog": 60,
"sm posting": 7,
"weekly work": 5,
"idea": 3,
"brochure": 10,
"news": 40,
"demos": 20,
"oc volunteer": 30,
"oc assigned": 20,
"oc no work": 10,
"oc manager": 50,
"wtf": 75,
"discord": 10,
"marketing": 20,
"mini project": 100,
"complete project": 200,
"promotion medium": 25,
"promotion large": 50
}
```

### 3. Run using docker

```sh
docker build -t cyscomvit/discord-bot:latest .
Expand Down
20 changes: 11 additions & 9 deletions bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ def check_if_required_env_variables_are_present():
}
if not all(env in environ for env in required_env_variables):
raise RuntimeError(
f"The following required environmental variables have not been set - {list(x for x in required_env_variables if x not in environ)}. Refer to code and Readme.MD for seeing what env keys are needed"
f"The following required environmental variables have not been set - {set(x for x in required_env_variables if x not in environ)}. Refer to code and Readme.MD for seeing what env keys are needed"
)


Expand Down Expand Up @@ -106,7 +106,7 @@ async def ping(ctx):

@bot.command()
async def doge(ctx):
"""Return a doge pic"""
"""Return a doge pic."""
try:
doge_pic_url = requests_get(
"https://shibe.online/api/shibes?count=1&urls=true"
Expand All @@ -120,14 +120,14 @@ async def doge(ctx):

@bot.command()
async def sum(ctx, numOne: int, numTwo: int):
f"""Return a sum of 2 numbers. {command_prefix} sum num1 num2"""
"""Return a sum of 2 numbers. !cyscom sum num1 num2"""
await ctx.send(numOne + numTwo)


@bot.command()
@commands.has_any_role("Cabinet Member")
async def add_member(ctx, name: str, rating: int = 0, contributions: int = 0):
f"""Add data to the leaderboard. Call it by {command_prefix} add_member "name" rating contribution"""
"""Add data to the leaderboard. Call it by !cyscom add_member "name" rating contribution"""
try:
data = leaderboard_ref.get()
name = name.strip()
Expand Down Expand Up @@ -179,7 +179,8 @@ async def add_member(ctx, name: str, rating: int = 0, contributions: int = 0):
@bot.command()
@commands.has_any_role("Cabinet Member")
async def add_recruits(ctx):
f"""Add recruits by reading a members.txt file present in the same folder"""
"""Add recruits by reading a members.txt file present in the same folder"""

# Place file in discord-bot folder.
try:
filename = "members.txt"
Expand Down Expand Up @@ -207,7 +208,7 @@ async def add_recruits(ctx):
@bot.command()
@commands.has_any_role("Cabinet Member")
async def set_points(ctx, name: str, rating=0, contributions=0):
f"""Specifically set a member's points. Call it by {command_prefix} set_points "name" rating contribution"""
"""Specifically set a member's points. Call it by !cyscom set_points "name" rating contribution"""
try:
data = leaderboard_ref.get()
name = name.strip()
Expand Down Expand Up @@ -248,7 +249,7 @@ async def set_points(ctx, name: str, rating=0, contributions=0):
@bot.command()
@commands.has_any_role("Member", "Cabinet Member")
async def fetch_data(ctx, name):
"""Fetch data from the leaderboard"""
"""Fetch data from the leaderboard. !cyscom fetch_data "name\" """
try:
data = leaderboard_ref.get()
if data != None:
Expand All @@ -270,7 +271,7 @@ async def fetch_data(ctx, name):
@bot.command()
@commands.has_any_role("Cabinet Member")
async def delete_data(ctx, name):
"""Delete someone from the leaderboard"""
"""Delete someone from the leaderboard. !cyscom delete_data "name\" """
try:
data = leaderboard_ref.get()
if data != None:
Expand Down Expand Up @@ -329,7 +330,7 @@ def fetch_points_for_each_task() -> dict[str, int]:
@bot.command()
@commands.has_any_role("Leaderboard", "Cabinet Member")
async def contribution(ctx, name, task):
# """Add contribution to a member"""
"""Add contribution to a member. !cyscom contribution "name" "task\""""
try:
data = leaderboard_ref.get()
if data != None:
Expand Down Expand Up @@ -368,6 +369,7 @@ async def contribution(ctx, name, task):
@bot.command()
@commands.has_any_role("Member", "Cabinet Member")
async def attendance(ctx, channel_name):
"""Attendance in a voice channel. !cyscom attendance "channel name\""""
f"""Mark attendance in a voice channel. Call by {command_prefix} attendance voice_channel_name"""

# Get the voice channel by name
Expand Down

0 comments on commit 34cfd1d

Please sign in to comment.