Skip to content

Commit f36bc19

Browse files
committed
Minor code quality changes
1 parent 68834c2 commit f36bc19

File tree

3 files changed

+37
-37
lines changed

3 files changed

+37
-37
lines changed

teapot/__init__.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ def copyright():
3535
return f"© 2020-{year()} RedCoke Development"
3636

3737

38-
def getPlatform():
38+
def platform():
3939
return platform.system() + " " + platform.release()
4040

4141

teapot/cogs/cmds.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,7 +86,7 @@ async def info(ctx):
8686
embed.add_field(name="Bot User:", value=bot.user)
8787
embed.add_field(name="Guilds:", value=len(bot.guilds))
8888
embed.add_field(name="Members:", value=len(set(bot.get_all_members())))
89-
embed.add_field(name="O.S.:", value=str(teapot.getPlatform()))
89+
embed.add_field(name="O.S.:", value=str(teapot.platform()))
9090
embed.add_field(name="Storage Type:", value=teapot.config.storage_type())
9191
embed.add_field(name="Prefix:", value=", ".join(teapot.config.bot_prefix()))
9292
embed.add_field(name="Github Repo:", value="[Teapot.py](https://github.com/RedCokeDevelopment/Teapot.py)")
@@ -191,7 +191,7 @@ async def debug(ctx):
191191
embed.add_field(name="Memory",
192192
value=str(round(psutil.virtual_memory()[1] / 1024 / 1024 / 1024)) + "GB / " + str(round(
193193
psutil.virtual_memory()[0] / 1024 / 1024 / 1024)) + "GB", inline=True)
194-
embed.add_field(name="O.S.:", value=str(teapot.getPlatform()), inline=True)
194+
embed.add_field(name="O.S.:", value=str(teapot.platform()), inline=True)
195195
embed.add_field(name="Storage Type:", value=teapot.config.storage_type(), inline=True)
196196
embed.add_field(name="Prefix:", value=", ".join(teapot.config.bot_prefix()), inline=True)
197197
embed.add_field(name="Github Repo:", value="[Teapot.py](https://github.com/RedCokeDevelopment/Teapot.py)",

teapot/cogs/neko.py

Lines changed: 34 additions & 34 deletions
Original file line numberDiff line numberDiff line change
@@ -8,87 +8,87 @@
88
from discord.ext import commands
99

1010
import teapot
11-
import teapot.tools.embed as dmbd
11+
import teapot.tools.embed as embed
12+
13+
14+
def neko_api(x):
15+
req = requests.get(f'https://nekos.life/api/v2/img/{x}')
16+
try:
17+
if req.status_code != 200:
18+
print("Unable to obtain neko image!")
19+
api_json = json.loads(req.text)
20+
url = api_json["url"]
21+
em = embed.newembed().set_image(url=url)
22+
return em
23+
except:
24+
return teapot.messages.error(f"obtaining image ({req.status_code})")
1225

1326

1427
class Neko(commands.Cog):
1528
"""Neko!!! :3"""
1629

1730
def __init__(self, bot):
18-
""" Initialize neko class"""
19-
31+
"""Initialize neko class"""
2032
self.bot = bot
2133

22-
def neko_api(self, ctx, x):
23-
try:
24-
req = requests.get(f'https://nekos.life/api/v2/img/{x}')
25-
if req.status_code != 200:
26-
print("Could not get a neko")
27-
apijson = json.loads(req.text)
28-
url = apijson["url"]
29-
em = dmbd.newembed().set_image(url=url)
30-
return em
31-
except:
32-
return teapot.messages.error(f"obtaining image ({req.status_code})")
33-
3434
@commands.command()
3535
async def neko(self, ctx):
36-
await ctx.send(embed=self.neko_api(ctx, "neko"))
36+
await ctx.send(embed=neko_api("neko"))
3737

3838
@commands.command()
3939
async def waifu(self, ctx):
40-
await ctx.send(embed=self.neko_api(ctx, "waifu"))
40+
await ctx.send(embed=neko_api("waifu"))
4141

4242
@commands.command()
4343
async def avatar(self, ctx):
44-
await ctx.send(embed=self.neko_api(ctx, "avatar"))
44+
await ctx.send(embed=neko_api("avatar"))
4545

4646
@commands.command()
4747
async def wallpaper(self, ctx):
48-
await ctx.send(embed=self.neko_api(ctx, "wallpaper"))
48+
await ctx.send(embed=neko_api("wallpaper"))
4949

5050
@commands.command()
5151
async def tickle(self, ctx):
52-
await ctx.send(embed=self.neko_api(ctx, "tickle"))
52+
await ctx.send(embed=neko_api("tickle"))
5353

5454
@commands.command()
5555
async def poke(self, ctx):
56-
await ctx.send(embed=self.neko_api(ctx, "poke"))
56+
await ctx.send(embed=neko_api("poke"))
5757

5858
@commands.command()
5959
async def kiss(self, ctx):
60-
await ctx.send(embed=self.neko_api(ctx, "kiss"))
60+
await ctx.send(embed=neko_api("kiss"))
6161

6262
@commands.command(aliases=['8ball'])
6363
async def eightball(self, ctx):
64-
await ctx.send(embed=self.neko_api(ctx, "8ball"))
64+
await ctx.send(embed=neko_api("8ball"))
6565

6666
@commands.command()
6767
async def lizard(self, ctx):
68-
await ctx.send(embed=self.neko_api(ctx, "lizard"))
68+
await ctx.send(embed=neko_api("lizard"))
6969

7070
@commands.command()
7171
async def slap(self, ctx):
72-
await ctx.send(embed=self.neko_api(ctx, "slap"))
72+
await ctx.send(embed=neko_api("slap"))
7373

7474
@commands.command()
7575
async def cuddle(self, ctx):
76-
await ctx.send(embed=self.neko_api(ctx, "cuddle"))
76+
await ctx.send(embed=neko_api("cuddle"))
7777

7878
@commands.command()
7979
async def goose(self, ctx):
80-
await ctx.send(embed=self.neko_api(ctx, "goose"))
80+
await ctx.send(embed=neko_api("goose"))
8181

8282
@commands.command()
8383
async def fox_girl(self, ctx):
84-
await ctx.send(embed=self.neko_api(ctx, "fox_girl"))
84+
await ctx.send(embed=neko_api("fox_girl"))
8585

8686
@commands.command()
8787
async def baka(self, ctx):
88-
await ctx.send(embed=self.neko_api(ctx, "baka"))
88+
await ctx.send(embed=neko_api("baka"))
8989

9090
@commands.command()
91-
async def hentai(self, ctx, type=""):
91+
async def hentai(self, ctx, api_type=""):
9292
if ctx.message.channel.nsfw:
9393
api_types = ['femdom', 'classic', 'ngif', 'erofeet', 'erok', 'les',
9494
'hololewd', 'lewdk', 'keta', 'feetg', 'nsfw_neko_gif', 'eroyuri',
@@ -97,13 +97,13 @@ async def hentai(self, ctx, type=""):
9797
'feet', 'smug', 'kemonomimi', 'solog', 'holo', 'bj', 'woof', 'yuri', 'trap', 'anal',
9898
'blowjob', 'holoero', 'feed', 'gasm', 'hentai', 'futanari', 'ero', 'solo', 'pwankg', 'eron',
9999
'erokemo']
100-
if type in api_types:
100+
if api_type in api_types:
101+
req = requests.get(f'https://nekos.life/api/v2/img/{api_type}')
101102
try:
102-
req = requests.get(f'https://nekos.life/api/v2/img/{type}')
103103
if req.status_code != 200:
104104
print("Unable to obtain image")
105-
apijson = json.loads(req.text)
106-
url = apijson["url"]
105+
api_json = json.loads(req.text)
106+
url = api_json["url"]
107107

108108
message = await ctx.send(embed=teapot.messages.downloading())
109109
async with aiohttp.ClientSession() as session:

0 commit comments

Comments
 (0)