-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
3 changed files
with
167 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -102,3 +102,6 @@ venv.bak/ | |
|
||
# mypy | ||
.mypy_cache/ | ||
|
||
# vscode | ||
.vscode/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 |