我正在制作一个机器人,在每个工作日的不同时间发布公告。我想通过5个discord任务循环在各自的日期发送公告来完成这一过程。它们将在各自的Unix时间戳上激活,然后在刷新下周的时间戳时重新激活。 如何生成在Unix时间戳上激活的@client.event
import discord
from discord.ext import commands, tasks
import random
import datetime
client = commands.Bot(command_prefix='.')
orig = datetime.datetime.fromtimestamp(1425917335)
new = orig + datetime.timedelta(days=90)
target_channel_id = 123456789
list_warning = ["T minus... 5 minutes... until detonation.", "Teacher is waiting. Get your ass back in 5 minutes.", "300 seconds unt-, 299 seconds unt-, 298 seconds unt-...",
"Chow down boys, lunch ends in 5 minutes.", "Looks like you've got some schoolin' to do."]
list_time = [1, 10]
#loops the 5 minute warning for lunch to end
@tasks.loop(seconds=)
async def called_once_a_day():
message_channel = client.get_channel(target_channel_id)
print(f"Got channel {message_channel}")
await message_channel.send(random.choice(list_warning))
org = orig + datetime.timedelta(days=7)
@called_once_a_day.before_loop
async def before():
await client.wait_until_ready()
print("Finished waiting")
called_once_a_day.start()
client.run("")
相关问题 更多 >
编程相关推荐