@@ -127,16 +127,26 @@ def __init__(
127127
128128 # session settings
129129 self .timeout_message = (
130- "Time is running out! You must make a choice within 60 seconds. ⏳ "
130+ "⏳ Hint: time is running out! You must make a choice within 60 seconds."
131131 )
132132 self ._timeout_task = None
133133 self .reset_timeout ()
134134
135135 def _get_game_data (self , game_code : str ) -> AdventureData | None :
136136 """Returns the game data for the given game code."""
137+ # sanitize the game code to prevent directory traversal attacks.
138+ game_code = Path (game_code ).name
139+
140+ # Convert index to game code if it's a number
141+ try :
142+ index = int (game_code )
143+ game_code = AVAILABLE_GAMES [index - 1 ]["id" ]
144+ self .game_code = game_code
145+ except (ValueError , IndexError ):
146+ pass
147+
148+ # load the game data from the JSON file
137149 try :
138- # sanitize the game code to prevent directory traversal attacks.
139- game_code = Path (game_code ).name
140150 game_data = json .loads (
141151 Path (f"{ BASE_PATH } /{ game_code } .json" ).read_text ("utf8" )
142152 )
@@ -168,16 +178,19 @@ def reset_timeout(self) -> None:
168178
169179 async def send_available_game_codes (self ) -> None :
170180 """Sends a list of all available game codes."""
171- available_game_codes = "\n " .join (
172- f"{ game ['id' ]} - { game ['name' ]} " for game in AVAILABLE_GAMES
181+ available_game_codes = "\n \n " .join (
182+ f"{ index } . **{ game ['name' ]} ** (`{ game ['id' ]} `)\n *{ game ['description' ]} *"
183+ for index , game in enumerate (AVAILABLE_GAMES , start = 1 )
173184 )
174185
175186 embed = Embed (
176- title = "Available games " ,
187+ title = "📋 Available Games " ,
177188 description = available_game_codes ,
178189 colour = constants .Colours .soft_red ,
179190 )
180191
192+ embed .set_footer (text = "💡 Hint: use `.adventure [game_code]` or `.adventure [index]` to start a game." )
193+
181194 await self .destination .send (embed = embed )
182195
183196 async def on_reaction_add (self , reaction : Reaction , user : User ) -> None :
@@ -250,14 +263,15 @@ def _format_room_data(self, room_data: RoomData) -> str:
250263 def embed_message (self , room_data : RoomData | EndRoomData ) -> Embed :
251264 """Returns an Embed with the requested room data formatted within."""
252265 embed = Embed ()
266+ embed .color = constants .Colours .soft_orange
253267
254268 current_game_name = AVAILABLE_GAMES_DICT [self .game_code ]["name" ]
255269
256270 if self .is_in_ending_room :
257271 embed .description = room_data ["text" ]
258272 emoji = room_data ["emoji" ]
259- embed .set_author (name = f"Game over ! { emoji } " )
260- embed .set_footer (text = f"Thanks for playing - { current_game_name } " )
273+ embed .set_author (name = f"Game ended ! { emoji } " )
274+ embed .set_footer (text = f"✨ Thanks for playing { current_game_name } ! " )
261275 else :
262276 embed .description = self ._format_room_data (room_data )
263277 embed .set_author (name = current_game_name )
@@ -326,7 +340,11 @@ async def new_adventure(self, ctx: Context, game_code: str | None = None) -> Non
326340 await GameSession .start (ctx , game_code )
327341 except GameCodeNotFoundError as error :
328342 await ctx .send (str (error ))
329- return
343+
344+ @commands .command (name = "adventures" )
345+ async def list_adventures (self , ctx : Context ) -> None :
346+ """List all available adventure games."""
347+ await GameSession .start (ctx , None )
330348
331349
332350async def setup (bot : Bot ) -> None :
0 commit comments