Skip to content
This repository was archived by the owner on Mar 14, 2021. It is now read-only.

Team 9 #17

Open
wants to merge 18 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
88 changes: 86 additions & 2 deletions bot/cogs/snakes.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,10 @@
# coding=utf-8
import json
import logging
import random
from typing import Any, Dict

from discord import Embed
from discord.ext.commands import AutoShardedBot, Context, command

log = logging.getLogger(__name__)
Expand All @@ -28,8 +31,29 @@ async def get_snek(self, name: str = None) -> Dict[str, Any]:
:param name: Optional, the name of the snake to get information for - omit for a random snake
:return: A dict containing information on a snake
"""
with open('bot/db/snakes.json', 'r') as file:
snakes_dict = json.load(file)

@command()
if not name:
_, snake = random.choice(list(snakes_dict.items()))

elif name.lower() not in snakes_dict:
snake = "Not Found"

else:
snake = snakes_dict[name.lower()]
if snake['name'] == "python":
snake = {
'name': snake['name'],
'description': snake['description'],
'creator': snake['creator'],
'created': snake['created'],
'image': snake['image']
}

return snake

@command(name='get')
async def get(self, ctx: Context, name: str = None):
"""
Go online and fetch information about a snake
Expand All @@ -40,8 +64,68 @@ async def get(self, ctx: Context, name: str = None):
:param ctx: Context object passed from discord.py
:param name: Optional, the name of the snake to get information for - omit for a random snake
"""
snake = await self.get_snek(name)

if snake != "Not Found":
embed = Embed(
title=snake['name'].title(),
description=snake['description']
)

if snake['name'] != "python":
embed.add_field(name="Where can you find them?", value=snake['location'])
embed.add_field(name="Are they venomous?", value=snake['venomous'])
embed.set_image(url=snake['image'])
else:
embed.add_field(name="Who created it?", value=snake['creator'])
embed.add_field(name="When was it created?", value=snake['created'])
embed.set_thumbnail(url=snake['image'])
else:
embed = Embed(
title="Snake Not Found",
description="The snake you entered was not found."
)

await ctx.send(embed=embed)

@command(name='movies')
async def movies(self, ctx: Context, movie_name: str = None):
"""
Shows 5 snake movies. Warning: They are all pretty bad.
"""

with open('bot/db/movies.json', 'r') as file:
movies_dict = json.load(file)

if not movie_name:
embed = Embed(
title="Snake Movies",
description="A list of snake movies.",
)

for movie in movies_dict.values():
embed.add_field(name=movie['title'].title(), value=f"bot.movies('{movie['title'].title()}')\n\n")

embed.set_thumbnail(url="https://i.imgur.com/dB38NwN.png")

else:
movie_name = movie_name.lower()
if movie_name in movies_dict:
embed = Embed(
title=movies_dict[movie_name]['title'].title(),
description=movies_dict[movie_name]['description']
)

embed.add_field(name="Director", value=movies_dict[movie_name]['director'])
embed.add_field(name="Release Date", value=movies_dict[movie_name]['released'])
embed.set_image(url=movies_dict[movie_name]['image'])
else:
embed = Embed(
title="Movie Not Found",
description="The movie you entered was not found."
)

# Any additional commands can be placed here. Be creative, but keep it to a reasonable amount!
await ctx.send(embed=embed)


def setup(bot):
Expand Down
46 changes: 46 additions & 0 deletions bot/db/movies.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,46 @@
{
"snakes on a plane":
{
"title": "snakes on a plane",
"description": "An FBI agent takes on a plane full of deadly and venomous snakes, deliberately released to kill a witness being flown from Honolulu to Los Angeles to testify against a mob boss.",
"director": "David R. Ellis",
"released": "18 August 2006",
"image": "https://i.imgur.com/oxe9vyF.jpg"
},

"anaconda":
{
"title": "anaconda",
"description": "A 'National Geographic' film crew is taken hostage by an insane hunter, who takes them along on his quest to capture the world's largest - and deadliest - snake.",
"director": "Luis Llosa",
"released": "11 April 1997",
"image": "https://i.imgur.com/9fRXtXf.jpg"
},

"snakes" :
{
"title": "snakes",
"description": "A snake lover sends out venomous snakes and reptiles to kill his enemies.",
"director": "Arthur A. Names",
"released": "December 1974",
"image": "https://i.imgur.com/tWhqvJp.jpg"
},

"king cobra":
{
"title": "king cobra",
"description": "A mutated snake escapes from a laboratory and terrorizes the residents of a small California brewery town.",
"director": "David Hillenbrand",
"released": "10 August 1999",
"image": "https://i.imgur.com/egFXDoW.jpg"
},

"venom":
{
"title": "venom",
"description": "Terrorists in the process of kidnapping a child get trapped in a house with an extremely deadly snake.",
"director": "Piers Haggard",
"released": "29 January 1982",
"image": "https://i.imgur.com/izxwULE.jpg"
}
}
135 changes: 135 additions & 0 deletions bot/db/snakes.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,135 @@
{
"python":
{
"name": "python",
"description": "Python is an interpreted high-level programming language for general-purpose programming. Python has a design philosophy that emphasizes code readability, notably using significant whitespace. It provides constructs that enable clear programming on both small and large scales.",
"creator": "Guido van Rossum",
"created": "First concieved in the late 1980's.",
"image": "https://i.imgur.com/GDcwKmZ.png"
},

"cobra":
{
"name": "cobra",
"description": "Cobras are large and diverse group of snakes. There are 270 different types of cobras.",
"location": "Africa, Asia and Australia, usually in forests and areas near river.",
"venomous": "Yes",
"image": "https://i.imgur.com/WSnvhC0.jpg"
},

"anaconda":
{
"name": "anaconda",
"description": "Anacondas are the largest and heaviest known snakes. There are 4 types of anacondas.",
"location": "Tropical rainforests, lakes and swamps of South America. Anacondas are especially numerous near Amazon and Orinoco rivers.",
"venomous": "No",
"image": "https://i.imgur.com/MNIY8zX.jpg"
},

"black mamba":
{
"name": "black mamba",
"description": "Black mamba is one of the deadliest snakes on the planet. Black mamba can survive in different types of habitat: savannas, swamps, forests, woods and rocky areas.",
"location": "Eastern and Southern parts of Africa",
"venomous": "Yes",
"image": "https://i.imgur.com/aLbAFkE.jpg"
},

"rattlesnake":
{
"name": "rattlesnake",
"description": "Rattlesnakes are easily recognized animals. There are 32 known species of rattlesnakes. Major threats to survival of rattlesnakes are habitat loss and organized killing (extermination) due to fear of these creatures.",
"location": "North and South America.",
"venomous": "Yes",
"image": "https://i.imgur.com/BjWQ9Tv.jpg"
},

"boa constrictor":
{
"name": "boa constrictor",
"description": "Boa constrictor is a close relative of anaconda. Boa constrictor is known as one of the most beautiful snakes because of its colorful skin with interesting prints.",
"location": "South and Central America.",
"venomous": "No",
"image": "https://i.imgur.com/vuJeUwl.jpg"
},

"king snake":
{
"name": "king",
"description": "King snake is a type of snake that belongs to the colubrid family. There are 11 species and 45 subspecies of king snakes",
"location": "North, Central and South America. ",
"venomous": "No",
"image": "https://i.imgur.com/7XsXJGs.jpg"
},

"taipan":{
"name": "taipan",
"description": "The taipans are snakes of the genus Oxyuranus in the elapid family. They are large and fast-moving. The taipans are considered some of the most deadly known snakes.",
"location": "Australasia",
"venomous": "Yes",
"image": "https://i.imgur.com/Z0y52fm.jpg"
},

"sea snake":
{
"name": "sea snake",
"description": "Sea snakes are group of snakes adapted to the life in salty and brackish water. Sea snakes belong to the family of cobras.",
"location": "Indian and Pacific Ocean.",
"venomous": "Yes",
"image": "https://i.imgur.com/hEjQK0m.jpg"
},

"garter":
{
"name": "garter snake",
"description": "Garter snakes are among the most common snakes in some countries. Often kept as pets, they are relatively harmless, although some species do possess a mild neurotoxic venom.",
"location": "North America; from Canada to Florida",
"venomous": "No",
"image": "https://i.imgur.com/qTFD4ml.jpg"
},

"mole snake":
{
"name": "mole snake",
"description": "Mole snakes spend the vast majority of their time underground. Their muscular build and pointed snout make them adept at pushing themselves through sandy burrows after their prey which consists primarily of golden moles and mole/dune rats.",
"location": "South Africa",
"venomous": "No",
"image": "https://i.imgur.com/VQKg9kb.jpg"
},

"false cobra":
{
"name": "false cobra",
"description": "The name 'false cobra' comes from the fact that this is not a cobra. It imitates a cobra's stance by spreading its neck into a hood and hissing like the cobra. It can grow up to 1.5 metres in length and preys on rodents and lizards.",
"location": "Africa and the Middle East",
"venomous": "Yes",
"image": "https://i.imgur.com/xmkrI4v.jpg"
},

"ninia":
{
"name": "ninia",
"description": "Ninia is a genus of colubroid snakes commonly referred to as coffee snakes. The genus consists of 10 species.",
"location": "Mexico, Central America and northern South America.",
"venomous": "No",
"image": "https://i.imgur.com/4BUr6vH.jpg"
},

"sharp-tailed":
{
"name": "sharp-tailed",
"description": "The sharp-tailed snake averages from eight to twelve inches long as an adult. It is distinguished by its sharp tail spine, which is the protruding tip of the last tail vertebra. The spine is not toxic and cannot injure humans.",
"location": "Western United States and parts of British Colombia",
"venomous": "No",
"image": "https://i.imgur.com/SNX5p2Z.jpg"
},

"sunbeam":
{
"name": "sunbeam",
"description": "Sunbeam snakes are thicker than a large banana (with skin) as adults. Their scales are very smooth and the snake has a texture like rubber. Dirt doesn’t appear to stick to the scales.",
"location": "South East Asia",
"venomous": "No",
"image": "https://i.imgur.com/vBRnuxv.jpg"
}
}