- import asyncio
- from datetime import datetime
- # Definir función para enviar mensaje en un momento específico
- async def send_announcement(text, fecha_final, bot):
- while datetime.now() < fecha_final:
- # Esperar hasta el momento programado
- await asyncio.sleep(1)
- channel = await bot.fetch_channel(1088553275227377705)
- await channel.send(text)
- # Definir evento cuando el bot recibe un mensaje
- async def rem(ctx, message, hour, minutes, day, month, bot):
- # Separar los argumentos del mensaje
- print("Program")
- # Crear objeto datetime con la fecha y hora especificadas
- fecha_inicial = datetime.now()
- print("Inicial:", fecha_inicial)
- fecha_final = datetime(2023, 3, 24, 18, 40)
- print("Final:", fecha_final)
- # Calcular el tiempo restante hasta la fecha y hora especificadas
- time_left = fecha_final - fecha_inicial
- print(time_left)
- text = message
- # Iniciar temporizador para enviar el mensaje en la fecha y hora especificadas
- asyncio.get_event_loop().create_task(send_announcement(text, fecha_final, bot))
[text] 1
Viewer
*** This page was generated with the meta tag "noindex, nofollow". This happened because you selected this option before saving or the system detected it as spam. This means that this page will never get into the search engines and the search bot will not crawl it. There is nothing to worry about, you can still share it with anyone.
Editor
You can edit this paste and save as new:
File Description
- 1
- Paste Code
- 24 Mar-2023
- 1.09 Kb
You can Share it:
Latest Code Pastes