Advertisement
Brodown64

Untitled

Jun 14th, 2025
186
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 1.24 KB | None | 0 0
  1.  # crime scene
  2.     if message.content.strip().lower().startswith("$setup"):
  3.         await message.channel.send("Please enter a floating-point number:")
  4.  
  5.         def check(m):
  6.             return m.author == message.author and m.channel == message.channel
  7.  
  8.         try:
  9.             reply = await client.wait_for("message", timeout=30.0, check=check)
  10.             parts = reply.content.strip().split()
  11.  
  12.             if len(parts) != 2:
  13.                 await message.channel.send("You need to enter exactly two numbers.")
  14.                 return
  15.  
  16.             num1 = float(parts[0])
  17.             num2 = float(parts[1])
  18.             await message.channel.send(f"You entered: `{num1}` and `{num2}`")
  19.  
  20.             global current_temperature_2m
  21.            
  22.             current_temperature_2m = weather.fetch_weather(num1, num2)
  23.             await message.channel.send(f"Current temp: {current_temperature_2m}°F")
  24.  
  25.         except ValueError:
  26.             await message.channel.send("That wasn't a valid floating-point number.")
  27.         except asyncio.TimeoutError:
  28.             await message.channel.send("You took too long to respond.")
  29.  
  30.     if message.content.startswith('$weather'):
  31.         await message.channel.send(f'Weather: {current_temperature_2m}')
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement