Skip to content

Commit 271c45f

Browse files
committed
add dbcheck command
1 parent dcba168 commit 271c45f

File tree

1 file changed

+50
-0
lines changed

1 file changed

+50
-0
lines changed

draft_review.py

Lines changed: 50 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -233,6 +233,56 @@ async def debug(self, ctx: discord.ApplicationContext):
233233

234234
for page_list in master_list:
235235
await ctx.respond(embeds=page_list, ephemeral=True)
236+
237+
@discord.slash_command(name='dbcheck', description='Check database status')
238+
@commands.has_role(1159901879417974795) # Bot Wrangler role
239+
async def dbcheck(self, ctx: discord.ApplicationContext):
240+
await ctx.defer(ephemeral=True)
241+
242+
try:
243+
# Check if database file exists
244+
if not path.exists(self.db.db_path):
245+
await ctx.respond(f"Database file not found at: {self.db.db_path}", ephemeral=True)
246+
return
247+
248+
# Get all drafts
249+
drafts = self.db.get_all_drafts()
250+
251+
# Create debug info embed
252+
embed = discord.Embed(
253+
title="Database Status",
254+
color=discord.Color.blue()
255+
)
256+
257+
embed.add_field(
258+
name="Database Path",
259+
value=self.db.db_path,
260+
inline=False
261+
)
262+
263+
embed.add_field(
264+
name="Number of Drafts",
265+
value=str(len(drafts)),
266+
inline=False
267+
)
268+
269+
if drafts:
270+
# Show first few drafts as sample
271+
sample = list(drafts.items())[:5]
272+
sample_text = "\n".join(f"- {title}" for title, _ in sample)
273+
if len(drafts) > 5:
274+
sample_text += "\n..."
275+
276+
embed.add_field(
277+
name="Sample Drafts",
278+
value=sample_text or "None",
279+
inline=False
280+
)
281+
282+
await ctx.respond(embed=embed, ephemeral=True)
283+
284+
except Exception as e:
285+
await ctx.respond(f"Error checking database: {str(e)}", ephemeral=True)
236286

237287

238288
def setup(bot: commands.Bot):

0 commit comments

Comments
 (0)