Skip to content

Commit 8b9a43d

Browse files
committed
improve list attempt
1 parent 452cb2e commit 8b9a43d

File tree

1 file changed

+11
-13
lines changed

1 file changed

+11
-13
lines changed

draft_review.py

Lines changed: 11 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,9 @@ def populate_db(db: DraftDatabase):
8686
url = 'https://2b2t.miraheze.org/w/api.php'
8787

8888
try:
89-
print("=== DEBUG: Making API request ===")
9089
request = requests.get(url, params=params, headers=headers)
9190
request.raise_for_status()
9291

93-
print(f"=== DEBUG: API Response Status: {request.status_code} ===")
94-
print(f"=== DEBUG: API Response Headers: {dict(request.headers)} ===")
95-
print(f"=== DEBUG: API Response Content: {request.text[:200]}... ===")
96-
9792
json_data = request.json()
9893

9994
if 'query' not in json_data:
@@ -246,8 +241,6 @@ async def help(self, ctx: discord.ApplicationContext):
246241
color=0x24ff00)
247242
embed.add_field(name="List drafts awaiting review", value="/list", inline=False)
248243
embed.add_field(name="Vote on a draft", value="/vote <user> <article> <duration> <auto>", inline=False)
249-
# embed.add_field(name="Approve a draft", value='/approve <user> <article> <"category 1, category 2, etc.">', inline=False)
250-
# embed.add_field(name="Reject a draft", value='/reject <user> <article> <"reason">', inline=False)
251244
await ctx.respond(embed=embed)
252245

253246
async def approve(self, user, name, categories):
@@ -282,9 +275,12 @@ async def reject(self, user, name, summary):
282275
@discord.slash_command(name='list', description="Provides a list of all pending drafts")
283276
async def list(self, ctx: discord.ApplicationContext):
284277
try:
278+
# Defer the response immediately
279+
await ctx.defer()
280+
285281
drafts = self.db.get_all_drafts()
286282
if not drafts:
287-
await ctx.respond("No drafts found.")
283+
await ctx.followup.send("No drafts found.")
288284
return
289285

290286
# Create embeds
@@ -326,14 +322,16 @@ async def list(self, ctx: discord.ApplicationContext):
326322
master_list.append(new_list)
327323
master_list[counter].append(embed)
328324

329-
# Send all embeds in a single response
330-
await ctx.respond(embeds=master_list[0])
331-
for page_list in master_list[1:]:
325+
# Send all embeds using followup messages
326+
for i, page_list in enumerate(master_list):
332327
if page_list: # Only send if there are embeds
333-
await ctx.followup.send(embeds=page_list)
328+
if i == 0:
329+
await ctx.followup.send(embeds=page_list)
330+
else:
331+
await ctx.followup.send(embeds=page_list)
334332

335333
except Exception as e:
336-
await ctx.respond(f"Error listing drafts: {str(e)}")
334+
await ctx.followup.send(f"Error listing drafts: {str(e)}")
337335

338336
@discord.slash_command(name='debug', description='Intended for bot developers only')
339337
@commands.has_role(1159901879417974795)

0 commit comments

Comments
 (0)