mirror of https://codeberg.org/soteria/sox.git
feat: soteria plugin
This commit is contained in:
parent
5b9a8baa9b
commit
b7a5ce5f5f
|
|
@ -0,0 +1,29 @@
|
||||||
|
from disnake.ext import plugins
|
||||||
|
|
||||||
|
import disnake
|
||||||
|
import soteria
|
||||||
|
|
||||||
|
plugin = plugins.Plugin()
|
||||||
|
|
||||||
|
sot = soteria.Client(cache=soteria.MemoryCache())
|
||||||
|
|
||||||
|
@plugin.slash_command(description="gets the 5 most recent BANGERS (posts) from Soteria")
|
||||||
|
async def get_posts(inter: disnake.CommandInteraction):
|
||||||
|
await inter.response.defer()
|
||||||
|
r = await sot.request('GET', '/posts/all', params={"limit": 5})
|
||||||
|
embed_list = []
|
||||||
|
for post in r:
|
||||||
|
user = await soteria.User.fetch(sot, post["author"])
|
||||||
|
embed_list.append(disnake.Embed(title=f"Author: {user.display_name}", description=post["content"], color=disnake.Color.blue()))
|
||||||
|
await inter.edit_original_response(embeds=embed_list)
|
||||||
|
await sot.close()
|
||||||
|
|
||||||
|
@plugin.slash_command(description="fetches info on a Soteria user")
|
||||||
|
async def get_user(inter: disnake.CommandInteraction, id: int):
|
||||||
|
user = await soteria.User.fetch(sot, id)
|
||||||
|
em = disnake.Embed(title=f"Info For {user.username}", color=disnake.Color.blue())
|
||||||
|
em.add_field(name="Username", value=user.username)
|
||||||
|
em.add_field(name="Display Name", value=user.display_name)
|
||||||
|
await inter.response.send_message(embed=em)
|
||||||
|
|
||||||
|
setup, teardown = plugin.create_extension_handlers()
|
||||||
Loading…
Reference in New Issue