Move the webhook listener into a cog so that I have access to the bot for the action method.
This commit is contained in:
@@ -0,0 +1,38 @@
|
||||
import uvicorn
|
||||
from fastapi import FastAPI
|
||||
from nextcord.ext import commands
|
||||
|
||||
app = FastAPI()
|
||||
|
||||
|
||||
class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
|
||||
@commands.Cog.listener()
|
||||
async def on_ready(self):
|
||||
app.add_api_route("/message/", self.hello, methods=["POST"])
|
||||
config = uvicorn.Config(app=app, port=5000, log_level="info")
|
||||
server = uvicorn.Server(config)
|
||||
await server.serve()
|
||||
|
||||
async def hello(self):
|
||||
print("we did a webhook")
|
||||
return {"message": "webhook get"}
|
||||
|
||||
async def update_messages(self):
|
||||
# TODO everything
|
||||
|
||||
# git pull
|
||||
# if no change, return
|
||||
# for ever directory, sort the files by number then post
|
||||
# posting involves checking if there is a message for that particular file then editing it or creating a
|
||||
# new one. the message could be deleted, which would cause a new message to be sent and database updated.
|
||||
pass
|
||||
|
||||
|
||||
# This function will be called when this extension is loaded.
|
||||
# It is necessary to add these functions to the bot.
|
||||
def setup(bot: commands.Bot):
|
||||
"""Adds function to bot"""
|
||||
bot.add_cog(ClanMessages(bot))
|
||||
Reference in New Issue
Block a user