Skip to content

Commit d2288a7

Browse files
committed
Implemented Eightball Feature
1 parent ed46564 commit d2288a7

File tree

4 files changed

+42
-2
lines changed

4 files changed

+42
-2
lines changed

Teapot.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -96,12 +96,13 @@ async def on_ready():
9696
teapot.cogs.osu.setup(bot)
9797
teapot.cogs.github.setup(bot)
9898
teapot.cogs.cat.setup(bot)
99+
teapot.cogs.eightball.setup(bot)
99100
teapot.cogs.neko.setup(bot)
100101
if teapot.config.storage_type() == "mysql":
101102
for guild in bot.guilds:
102103
teapot.managers.database.create_guild_table(guild)
103104
elif teapot.config.storage_type() == "sqlite":
104-
print("[!] Warning: SQLite storage has not been implemented yet. MySQL database is recommended") # WIP
105+
print("[!] Warning: SQLite storage has not been implemented yet. MySQL is recommended") # WIP
105106
print(f"Registered commands and events in {round(time.perf_counter() - time_start, 2)}s")
106107
await bot.change_presence(status=discord.Status.online,
107108
activity=discord.Game(teapot.config.bot_status())) # Update Bot status

teapot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,7 +8,7 @@
88

99

1010
def version():
11-
return "v0.0.1.6"
11+
return "v0.0.1.7"
1212

1313

1414
def config_version():

teapot/cogs/__init__.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
from .cat import *
22
from .cmds import *
3+
from .eightball import *
34
from .github import *
45
from .music import *
56
from .neko import *

teapot/cogs/eightball.py

Lines changed: 38 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,38 @@
1+
""" Module for generating random neko pictures"""
2+
import io
3+
import json
4+
5+
import aiohttp
6+
import discord
7+
import requests
8+
from discord.ext import commands
9+
10+
import teapot
11+
import teapot.tools.embed as dmbd
12+
13+
14+
class EightBall(commands.Cog):
15+
"""8 Ball"""
16+
17+
def __init__(self, bot):
18+
""" Initialize 8ball class"""
19+
self.bot = bot
20+
21+
def eightball_api(self, ctx):
22+
try:
23+
req = requests.get(f'https://nekos.life/api/v2/8ball/{x}')
24+
if req.status_code != 200:
25+
print("Could not get a response")
26+
apijson = json.loads(req.text)
27+
em = dmbd.newembed().set_image(url=apijson["url"])
28+
return em
29+
except:
30+
return teapot.messages.error(f"obtaining 8ball image ({req.status_code})")
31+
32+
@commands.command(pass_context=True)
33+
async def eightball(self, ctx):
34+
await ctx.send(embed=self.eightball_api(ctx))
35+
36+
def setup(bot):
37+
""" Setup Eight Ball Module"""
38+
bot.add_cog(EightBall(bot))

0 commit comments

Comments
 (0)