Skip to content

Commit 63539b9

Browse files
committed
Link github webhook data docs for each payload type for developer convenience
1 parent 18fee81 commit 63539b9

1 file changed

Lines changed: 13 additions & 4 deletions

File tree

fred/libraries/createembed.py

Lines changed: 13 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ def DM(text: str) -> nextcord.Embed:
7979
return embed
8080

8181

82+
# data format: expand `commits` properties on: https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
8283
def format_commit(commit: dict) -> tuple[str, str]:
8384
hash_id = f'`{commit["id"][:8]}`'
8485
commit_message = commit["message"].split("\n")[0].replace("*", r"\*")
@@ -91,6 +92,7 @@ def format_commit(commit: dict) -> tuple[str, str]:
9192
return f"{commit_message}\n", f'{change_summary_icons} - by {attribution} {ts} [{hash_id}]({commit["url"]})\n'
9293

9394

95+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
9496
def push(data: dict) -> nextcord.Embed:
9597
if data["forced"]:
9698
colour = config.ActionColours.fetch("Red")
@@ -100,10 +102,10 @@ def push(data: dict) -> nextcord.Embed:
100102
forced = ""
101103

102104
if data["created"]:
103-
embed = create(data)
105+
embed = push_ref_create(data)
104106
return embed
105107
elif data["deleted"]:
106-
embed = delete(data)
108+
embed = push_ref_delete(data)
107109
return embed
108110

109111
commits = data["commits"]
@@ -127,6 +129,7 @@ def push(data: dict) -> nextcord.Embed:
127129
return embed
128130

129131

132+
# data format: (note: docs on 'added' has empty data for `member` but it probably shares it with 'removed'?) https://docs.github.com/en/webhooks/webhook-events-and-payloads?actionType=removed#member
130133
def contributor_added(data: dict) -> nextcord.Embed:
131134
embed = nextcord.Embed(
132135
title=f'__**{data["member"]["login"]}**__ has been added to the Repository!',
@@ -139,6 +142,7 @@ def contributor_added(data: dict) -> nextcord.Embed:
139142
return embed
140143

141144

145+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#pull_request
142146
def pull_request(data: dict) -> nextcord.Embed:
143147
action = data["action"]
144148
colour = config.ActionColours.fetch("Orange")
@@ -189,7 +193,8 @@ def pull_request(data: dict) -> nextcord.Embed:
189193
return embed
190194

191195

192-
def create(data: dict) -> nextcord.Embed:
196+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
197+
def push_ref_create(data: dict) -> nextcord.Embed:
193198
_, ref_type, ref_name = data["ref"].split("/")
194199
match ref_type:
195200
case "tags":
@@ -210,7 +215,8 @@ def create(data: dict) -> nextcord.Embed:
210215
return embed
211216

212217

213-
def delete(data: dict) -> nextcord.Embed:
218+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#push
219+
def push_ref_delete(data: dict) -> nextcord.Embed:
214220
_, ref_type, ref_name = data["ref"].split("/")
215221
embed = nextcord.Embed(
216222
title=f'{ref_type} "{ref_name}" deleted in {repo_name}',
@@ -223,6 +229,7 @@ def delete(data: dict) -> nextcord.Embed:
223229
return embed
224230

225231

232+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#release
226233
def release(data: dict) -> nextcord.Embed:
227234
state = "pre-release" if data["release"]["prerelease"] else "release"
228235
embed = nextcord.Embed(
@@ -236,6 +243,7 @@ def release(data: dict) -> nextcord.Embed:
236243
return embed
237244

238245

246+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#issues
239247
def issue(data: dict) -> nextcord.Embed:
240248
match action := data["action"]:
241249
case "opened":
@@ -257,6 +265,7 @@ def issue(data: dict) -> nextcord.Embed:
257265
return embed
258266

259267

268+
# data format: https://docs.github.com/en/webhooks/webhook-events-and-payloads#issue_comment
260269
def issue_comment(data: dict) -> nextcord.Embed:
261270
author = data["comment"]["user"]
262271
embed = nextcord.Embed(

0 commit comments

Comments
 (0)