Skip to content

Commit

Permalink
Adding main functionality
Browse files Browse the repository at this point in the history
  • Loading branch information
israelvf committed Nov 27, 2019
1 parent 09d10c1 commit 26d368e
Show file tree
Hide file tree
Showing 3 changed files with 167 additions and 0 deletions.
3 changes: 3 additions & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -102,3 +102,6 @@ venv.bak/

# mypy
.mypy_cache/

# vscode
.vscode/
141 changes: 141 additions & 0 deletions main.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,141 @@
import os
import discord
from discord.ext import commands
from dotenv import load_dotenv

load_dotenv()
token = os.getenv("DISCORD_TOKEN")

bot = commands.Bot(command_prefix="!")

lists_dict = {}


@bot.command(name="new", help="Creates a new todo list")
async def create_list(ctx, list_name):
embed = discord.Embed()
list_name = list_name.lower()
if list_name in lists_dict:
embed.color = 0xff0000
embed.title = f"**List already exists!**"
embed.description = f"{list_name.capitalize()} already exists"
else:
embed.color = 0x00ff00
embed.title = f"**List has been created!**"
embed.description = f"New list {list_name.capitalize()} has been created!"
lists_dict[list_name] = {}
await ctx.send(embed=embed)


@bot.command(name="delete", help="Removes todo list")
async def delete_list(ctx, list_name):
embed = discord.Embed()
list_name = list_name.lower()
if lists_dict.pop(list_name, None) is None:
embed.color = 0xff0000
embed.title = f"**List not found!**"
embed.description = f"{list_name.capitalize()} was not found"
else:
embed.color = 0x00ff00
embed.title = f"**List has been removed!**"
embed.description = f"{list_name.capitalize()} has been removed!"
await ctx.send(embed=embed)


@bot.command(name="add", help="Adds item to list")
async def add_item(ctx, item, list_name):
embed = discord.Embed()
item = item.lower()
list_name = list_name.lower()
if list_name not in lists_dict:
embed.color = 0xff0000
embed.title = f"**List not found!**"
embed.description = f"{list_name.capitalize()} was not found"
else:
lists_dict[list_name][item] = False
embed.color = 0x00ff00
embed.title = list_name.capitalize()
items = ""
for item in lists_dict[list_name]:
if lists_dict[list_name][item]:
items += f"~~[X] {item.capitalize()}~~\n"
else:
items += f"[ \u200B \u200B ] {item.capitalize()}\n"
embed.description = items
await ctx.send(embed=embed)


@bot.command(name="remove", help="Removes item from list")
async def remove_item(ctx, item, list_name):
embed = discord.Embed()
item = item.lower()
list_name = list_name.lower()
if list_name not in lists_dict:
embed.color = 0xff0000
embed.title = f"**List not found!**"
embed.description = f"{list_name.capitalize()} was not found"
elif item not in lists_dict[list_name]:
embed.color = 0xff0000
embed.title = f"**Item was not found on list!**"
embed.description = f"{item.capitalize()} was not found in {list_name.capitalize()}"
else:
lists_dict[list_name].pop(item, None)
embed.color = 0x00ff00
embed.title = list_name.capitalize()
items = ""
for item in lists_dict[list_name]:
if lists_dict[list_name][item]:
items += f"~~[X] {item.capitalize()}~~\n"
else:
items += f"[ \u200B \u200B ] {item.capitalize()}\n"
embed.description = items
await ctx.send(embed=embed)


@bot.command(name="done", help="Sets item as done")
async def set_done(ctx, item, list_name):
embed = discord.Embed()
item = item.lower()
list_name = list_name.lower()
if list_name not in lists_dict:
embed.color = 0xff0000
embed.title = f"**List not found!**"
embed.description = f"{list_name.capitalize()} was not found"
elif item not in lists_dict[list_name]:
embed.color = 0xff0000
embed.title = f"**Item was not found on list!**"
embed.description = f"{item.capitalize()} was not found in {list_name.capitalize()}"
else:
lists_dict[list_name][item] = True
embed.color = 0x00ff00
embed.title = list_name.capitalize()
items = ""
for item in lists_dict[list_name]:
if lists_dict[list_name][item]:
items += f"~~[X] {item.capitalize()}~~\n"
else:
items += f"[ \u200B \u200B ] {item.capitalize()}\n"
embed.description = items
await ctx.send(embed=embed)


@bot.command(name="show", help="Shows list contents")
async def show_list(ctx, list_name):
embed = discord.Embed()
list_name = list_name.lower()
if list_name not in lists_dict:
embed.color = 0xff0000
embed.title = f"**List not found!**"
embed.description = f"{list_name.capitalize()} was not found"
else:
embed.title = list_name.capitalize()
items = ""
for item in lists_dict[list_name]:
if lists_dict[list_name][item]:
items += f"~~[X] {item.capitalize()}~~\n"
else:
items += f"[ \u200B \u200B ] {item.capitalize()}\n"
embed.description = items
await ctx.send(embed=embed)

bot.run(token)
23 changes: 23 additions & 0 deletions requirements.txt
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
aiohttp==3.5.4
astroid==2.3.3
async-timeout==3.0.1
attrs==19.3.0
autopep8==1.4.4
chardet==3.0.4
discord==1.0.1
discord.py==1.2.5
idna==2.8
idna-ssl==1.1.0
isort==4.3.21
lazy-object-proxy==1.4.3
mccabe==0.6.1
multidict==4.6.1
pycodestyle==2.5.0
pylint==2.4.4
python-dotenv==0.10.3
six==1.13.0
typed-ast==1.4.0
typing-extensions==3.7.4.1
websockets==6.0
wrapt==1.11.2
yarl==1.3.0

0 comments on commit 26d368e

Please sign in to comment.