Fill out some docustrings
This commit is contained in:
@@ -1,3 +1,7 @@
|
||||
"""
|
||||
File contains logic for creating a webhook listener, pulling from git, and updating all messages.
|
||||
"""
|
||||
|
||||
import os
|
||||
|
||||
import nextcord
|
||||
@@ -18,6 +22,11 @@ MESSAGES_DIR = f"{REPO_DIR}/messages"
|
||||
|
||||
|
||||
class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
"""
|
||||
Cog to be loaded into the bot. Used to be able to have a fastapi post listener and access to the bot at
|
||||
the same time.
|
||||
"""
|
||||
|
||||
def __init__(self, bot: commands.Bot):
|
||||
self.bot = bot
|
||||
self.config: DakinyConfig = self.bot.config
|
||||
@@ -29,18 +38,14 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
Triggers when the bot is in ready state. Adds the webhook listener to FastAPI and serves.
|
||||
"""
|
||||
await self.update_messages()
|
||||
app.add_api_route("/message/", self.hello, methods=["POST"])
|
||||
app.add_api_route("/messages/", self.update_messages, methods=["POST"])
|
||||
config = uvicorn.Config(app=app, port=5000, log_level="info")
|
||||
server = uvicorn.Server(config)
|
||||
await server.serve()
|
||||
|
||||
async def hello(self):
|
||||
await self.update_messages()
|
||||
return
|
||||
|
||||
async def update_messages(self):
|
||||
"""
|
||||
_summary_
|
||||
Pulls from git and then updates all the discord messages as described by the files in the git repo.
|
||||
"""
|
||||
|
||||
self.origin.pull()
|
||||
@@ -92,6 +97,8 @@ class ClanMessages(commands.Cog, name="Clan Messages"):
|
||||
session.execute(stmt)
|
||||
session.commit()
|
||||
|
||||
return {"message": "Successfully updated all discord messages."}
|
||||
|
||||
async def get_clan_message_channel(
|
||||
self, session: Session, channel_name: str, guild: nextcord.Guild
|
||||
) -> nextcord.TextChannel:
|
||||
|
||||
Reference in New Issue
Block a user