Skip to content

Commit e8abeb9

Browse files
committed
fix: SRA endpoint updates
1 parent 664abf0 commit e8abeb9

3 files changed

Lines changed: 70 additions & 40 deletions

File tree

commands/anime.py

Lines changed: 9 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -36,13 +36,18 @@ async def news(self, interaction: discord.Interaction):
3636
value=f"{news.description[i][:200]}...\n[Read more]({news.links[i]})", inline=False)
3737
await interaction.response.send_message(embed=embed)
3838

39-
# currently not working (some random api has some issues)
4039
@app_commands.command(name="gif", description="Get an anime gif")
4140
@app_commands.describe(topic="The topic you want to search")
42-
@app_commands.choices(topic=[app_commands.Choice(name="face palm", value="face-palm"),
43-
app_commands.Choice(name="wink", value="wink"),
41+
@app_commands.choices(topic=[app_commands.Choice(name="nom", value="nom"),
42+
app_commands.Choice(name="poke", value="poke"),
43+
app_commands.Choice(name="cry", value="cry"),
44+
app_commands.Choice(name="kiss", value="kiss"),
4445
app_commands.Choice(name="pat", value="pat"),
45-
app_commands.Choice(name="hug", value="hug")])
46+
app_commands.Choice(name="hug", value="hug"),
47+
app_commands.Choice(name="wink", value="wink"),
48+
app_commands.Choice(name="face palm", value="face-palm"),
49+
# app_commands.Choice(name="quote", value="quote")
50+
])
4651
async def gif(self, interaction: discord.Interaction, topic: discord.app_commands.Choice[str]):
4752
url = requests.get(f"{SRA_BASE_URL}/animu/{topic.value}").json()['link']
4853
embed = discord.Embed(title=f":goblin: Anime GIF: {topic.name}", url=url, colour=discord.Colour(0x00ff00))

commands/fun.py

Lines changed: 5 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -9,15 +9,17 @@
99
class FunCommands(app_commands.Group):
1010
@app_commands.command(name="animal", description="Get a random image & fact about an animal")
1111
@app_commands.describe(animal="The desired animal")
12-
@app_commands.choices(animal=[app_commands.Choice(name="bird", value="bird"),
12+
@app_commands.choices(animal=[app_commands.Choice(name="birb", value="birb"),
13+
app_commands.Choice(name="bird", value="bird"),
1314
app_commands.Choice(name="cat", value="cat"),
1415
app_commands.Choice(name="dog", value="dog"),
1516
app_commands.Choice(name="fox", value="fox"),
1617
app_commands.Choice(name="kangaroo", value="kangaroo"),
1718
app_commands.Choice(name="koala", value="koala"),
1819
app_commands.Choice(name="panda", value="panda"),
19-
app_commands.Choice(name="raccoon", value="raccoon"),
20-
app_commands.Choice(name="red panda", value="red_panda"), ])
20+
app_commands.Choice(name="raccoon", value="racoon"),
21+
app_commands.Choice(name="red panda", value="red_panda"),
22+
app_commands.Choice(name="whale", value="whale")])
2123
async def fun_animal(self, interaction: discord.Interaction, animal: discord.app_commands.Choice[str]):
2224
url = f"{SRA_BASE_URL}/animal/{animal.value}"
2325
r = requests.get(url)
@@ -46,7 +48,6 @@ async def fun_hack(self, interaction: discord.Interaction, user: discord.Member)
4648
"https://c.tenor.com/VrzXhtoSwcsAAAAC/tenor.gif",
4749
"https://c.tenor.com/19Ev9JAezGEAAAAC/tenor.gif",
4850
"https://c.tenor.com/5Xw3hRmmtsoAAAAC/tenor.gif"]
49-
token = requests.get("https://some-random-api.com/others/bottoken").json()['token']
5051
token = requests.get(f"{SRA_BASE_URL}/bottoken").json()['token']
5152

5253
embed = discord.Embed(title=f":space_invader: [1/8] Hacking {user.name}",

commands/image.py

Lines changed: 56 additions & 32 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
import discord
22
from discord import app_commands
3-
from io import BytesIO
4-
import requests
53
import urllib
64
from urllib import parse
75
from settings.settings import SRA_BASE_URL
@@ -10,12 +8,15 @@
108
class ImageCommands(app_commands.Group):
119
@app_commands.command(name="effect", description="Apply an effect to the pfp of a user")
1210
@app_commands.describe(effect="The desired effect", member="The desired user")
13-
@app_commands.choices(effect=[app_commands.Choice(name="comrade", value="comrade"),
11+
@app_commands.choices(effect=[app_commands.Choice(name="circle", value="circle"),
12+
app_commands.Choice(name="comrade", value="comrade"),
1413
app_commands.Choice(name="gay", value="gay"),
1514
app_commands.Choice(name="glass", value="glass"),
15+
app_commands.Choice(name="heart", value="heart"),
1616
app_commands.Choice(name="horny license", value="horny"),
1717
app_commands.Choice(name="jail", value="jail"),
1818
app_commands.Choice(name="lgbt", value="lgbt"),
19+
app_commands.Choice(name="lied", value="lied"),
1920
app_commands.Choice(name="lolice", value="lolice"),
2021
app_commands.Choice(name="mission passed", value="passed"),
2122
app_commands.Choice(name="simp card", value="simpcard"),
@@ -24,31 +25,36 @@ class ImageCommands(app_commands.Group):
2425
async def effect(self, interaction: discord.Interaction, member: discord.Member,
2526
effect: discord.app_commands.Choice[str]):
2627
pfp_url = member.display_avatar
27-
# Only triggered is a gif, all others are static images => same code
28-
# NEED TO FIX LATER, TRIGGERED SHOULD BE IN EMBED FOR CONSISTENCY
29-
if effect.name == "triggered":
30-
try:
31-
response = requests.get(f"{SRA_BASE_URL}/canvas/triggered?avatar={str(pfp_url)}").content
32-
image_data = BytesIO(response)
33-
# embed = discord.Embed(title="✨ ImageEffect: " + effect.name, colour=discord.Colour(0x00ff00),
34-
# description=member.mention)
35-
# embed.set_image(url="attachment://triggered.gif")
36-
# await interaction.response.send_message(embed=embed)
37-
await interaction.response.send_message(file=discord.File(image_data, 'triggered.gif'))
38-
except KeyError:
39-
# {"error":{"error":"Image given has not completed loading"}}
40-
await interaction.response.send_message("Error making triggered image!", ephemeral=True)
41-
else:
42-
try:
43-
url = f"{SRA_BASE_URL}/canvas/{effect.value}?avatar={str(pfp_url)}"
28+
29+
try:
30+
# /canvas/overlay endpoints
31+
if effect.value in ["comrade", "gay", "glass", "jail", "passed", "triggered", "wasted"]:
32+
url = f"{SRA_BASE_URL}/canvas/overlay/{effect.value}?avatar={str(pfp_url)}"
33+
embed = discord.Embed(title="✨ ImageEffect: " + effect.name, colour=discord.Colour(0x00ff00),
34+
description=member.mention)
35+
embed.set_image(url=url)
36+
await interaction.response.send_message(embed=embed)
37+
38+
# /canvas/misc endpoints
39+
elif effect.value in ["circle", "heart", "horny", "lgbt", "lolice", "simpcard"]:
40+
url = f"{SRA_BASE_URL}/canvas/misc/{effect.value}?avatar={str(pfp_url)}"
4441
embed = discord.Embed(title="✨ ImageEffect: " + effect.name, colour=discord.Colour(0x00ff00),
4542
description=member.mention)
4643
embed.set_image(url=url)
4744
await interaction.response.send_message(embed=embed)
48-
except KeyError:
49-
embed = discord.Embed(title=":x: Error", colour=discord.Colour(0xff0000),
50-
description="Image could not be created!")
51-
await interaction.response.send_message(embed=embed, ephemeral=True)
45+
46+
elif effect.value == "lied":
47+
url = f"{SRA_BASE_URL}/canvas/misc/{effect.value}?username={member.display_name}&avatar={str(pfp_url)}"
48+
embed = discord.Embed(title="✨ ImageEffect: " + effect.name, colour=discord.Colour(0x00ff00),
49+
description=member.mention)
50+
embed.set_image(url=url)
51+
await interaction.response.send_message(embed=embed)
52+
53+
except KeyError:
54+
embed = discord.Embed(title=":x: Error", colour=discord.Colour(0xff0000),
55+
description="Image could not be created!")
56+
await interaction.response.send_message(embed=embed, ephemeral=True)
57+
5258

5359
@app_commands.command(name="filter", description="Apply a simple filter to the pfp of a user")
5460
@app_commands.describe(filter="The desired filter", member="The desired user")
@@ -81,18 +87,36 @@ async def filter(self, interaction: discord.Interaction, member: discord.Member,
8187
@app_commands.command(name="compose", description="Create meme-y images")
8288
@app_commands.describe(effect="The desired effect", member="The desired user", text="The text to put on the image")
8389
@app_commands.choices(effect=[app_commands.Choice(name="youtube comment", value="youtube-comment"),
84-
app_commands.Choice(name="twitter post", value="tweet"),])
90+
app_commands.Choice(name="twitter post", value="tweet"),
91+
app_commands.Choice(name="oh no it's stupid", value="its-so-stupid")])
8592
async def compose(self, interaction: discord.Interaction, member: discord.Member,
8693
effect: discord.app_commands.Choice[str], text: str):
8794
text = urllib.parse.quote(text)
8895
name = urllib.parse.quote(member.name)
89-
displayname = urllib.parse.quote(member.display_name)
90-
url = f"{SRA_BASE_URL}/canvas/misc/{effect.value}?avatar={member.display_avatar}&comment={text}"
91-
f"&username={name}&displayname={displayname}"
92-
embed = discord.Embed(title="✨ ImageCompose: " + effect.name, colour=discord.Colour(0x00ff00),
93-
description=member.mention)
94-
embed.set_image(url=url)
95-
await interaction.response.send_message(embed=embed)
96+
display_name = urllib.parse.quote(member.display_name)
97+
98+
if effect.value == "youtube-comment":
99+
url = (f"{SRA_BASE_URL}/canvas/misc/{effect.value}?username={name}&comment={text}"
100+
f"&avatar={member.display_avatar}")
101+
embed = discord.Embed(title="✨ ImageCompose: " + effect.name, colour=discord.Colour(0x00ff00),
102+
description=member.mention)
103+
embed.set_image(url=url)
104+
await interaction.response.send_message(embed=embed)
105+
106+
elif effect.value == "tweet":
107+
url = (f"{SRA_BASE_URL}/canvas/misc/{effect.value}?username={name}&displayname={display_name}"
108+
f"&comment={text}&avatar={member.display_avatar}")
109+
embed = discord.Embed(title="✨ ImageCompose: " + effect.name, colour=discord.Colour(0x00ff00),
110+
description=member.mention)
111+
embed.set_image(url=url)
112+
await interaction.response.send_message(embed=embed)
113+
114+
elif effect.value == "its-so-stupid":
115+
url = f"{SRA_BASE_URL}/canvas/misc/{effect.value}?dog={text}&avatar={member.display_avatar}"
116+
embed = discord.Embed(title="✨ ImageCompose: " + effect.name, colour=discord.Colour(0x00ff00),
117+
description=member.mention)
118+
embed.set_image(url=url)
119+
await interaction.response.send_message(embed=embed)
96120

97121

98122
async def setup(bot):

0 commit comments

Comments
 (0)