如何解决如何使事件在特定的Unix时间戳上激活在discord.py中?
我正在制作一个在每个工作日的不同时间发布公告的漫游器。我想通过使5个不一致的任务循环在相应的日期发送公告来完成这一过程。他们将在各自的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("")
解决方法
我会考虑一个更幼稚的解决方案。只需经常循环并检查您是否在午餐时间,如果是,则发送午餐消息。我倾向于使用箭头,因为我发现它易于使用...您可以使用其他库实现
layout(push_constant) uniform vertexPushConstants {
layout(offset = 0) float time;
} u_pushConstants;
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。