Skip to content

Commit f72d3d5

Browse files
committed
Add some debugging
1 parent 17d9345 commit f72d3d5

File tree

2 files changed

+23
-2
lines changed

2 files changed

+23
-2
lines changed

extensions/tito.py

Lines changed: 22 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import aiohttp, discord, logging, utils
1+
import discord, json, logging, utils
22

33
from discord.ext import commands, tasks
44
from env import env
@@ -20,7 +20,9 @@ async def on_ready(self):
2020
@tasks.loop(seconds=60.0)
2121
async def pull_answers(self):
2222
answers = await self.api.fetch_question_answers(env.TITO_QUESTION_SLUG)
23+
logging.debug(f"Received {len(answers)} answers in latest API response.")
2324
for a in answers:
25+
logging.debug(f"Stored answer for {a.response}")
2426
self.attendees[a.response] = a.ticket_id
2527

2628
# TODO: allow to be used as user command
@@ -63,16 +65,35 @@ async def ticketof(self, ctx: discord.ApplicationContext, user: discord.Member):
6365

6466
await ctx.respond(f"ℹ️ I found a ticket for `{user.name}`. Their ticket ID is `{ticket}`.", ephemeral=True)
6567

68+
@commands.slash_command(description="A debug command to get the internal cache.")
69+
@commands.guild_only()
70+
async def tickets(self, ctx: discord.ApplicationContext):
71+
# Normal users can't do this
72+
if not utils.is_volunteer(ctx.author):
73+
logging.warning(f"User {ctx.author.name} attempted to user a forbidden command.")
74+
return await ctx.respond("✋ Only organisers can do this.", ephemeral=True)
75+
76+
tickets = json.dumps(
77+
self.attendees,
78+
sort_keys=True,
79+
indent=4,
80+
separators=(',', ': ')
81+
)
82+
await ctx.respond(f"```json\n{tickets}\n```", ephemeral=True)
83+
6684
@commands.Cog.listener()
6785
async def on_member_join(self, member: discord.Member):
6886
if member.guild.id != env.DISCORD_GUILD_ID:
87+
logging.debug(f"Skipping automatic verification for {member.name} because they joined a different guild.")
6988
return
7089

7190
if member.bot:
91+
logging.debug(f"Skipping automatic verification for {member.name} because they are a bot.")
7292
return
7393

7494
ticket = self.attendees.get(member.name)
7595
if ticket is None:
96+
logging.debug(f"Skipping automatic verification for {member.name} because no ticket was found in cache.")
7697
return
7798

7899
await member.add_roles(member.guild.get_role(env.DISCORD_ATTENDEE_ROLE_ID))

main.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
format="%(asctime)s %(levelname)s: %(message)s",
88
datefmt="%d-%m-%Y %H:%M:%S",
99
encoding="utf-8",
10-
level=logging.INFO)
10+
level=logging.DEBUG)
1111

1212
intents = discord.Intents.default()
1313
intents.members = True

0 commit comments

Comments
 (0)