我正在开发一个机器人,以促进我们团队现有的一些工作。有了这些,我开始创建一些运行良好的任务,我需要创建一个从周一到周五16点运行的通知,我看到了一些博客,我尝试应用,但没有成功,今天这是我的代码,我想调用的函数名为“LEMBRAR()”,我想知道我必须运行这个函数的选项
import discord
from discord.ext import commands, tasks
from discord.ext.commands import has_permissions
from BotGooBee.Humor import GooBee
hora = '16:00'
diasSemanas = 'seg-sex'
client = commands.Bot(command_prefix='?')
@client.event
async def on_ready():
print('bot online')
@client.command()
async def limpar(ctx, amount=100):
await ctx.channel.purge(limit=amount)
@client.command()
async def ping(ctx):
await ctx.send(f'Pong! {round(client.latency * 1000)}ms')
@client.command()
async def feliz(ctx):
GooBee(1).AtualizarHumor()
await ctx.send('Humor alterado | FELIZ')
@client.command()
async def normal(ctx):
GooBee(2).AtualizarHumor()
await ctx.send('Humor alterado | NORMAL')
@client.command()
async def irritado(ctx):
GooBee(3).AtualizarHumor()
await ctx.send('Humor alterado | IRRITADO')
async def lembrar():
print('hello')
channel = client.get_channel(id_channel)
await channel.send('hello')
client.run(token)
对于那些有疑问的人,我按照上面的提示发出了此警报,因此我在bot.loop.create_任务(my_def())的末尾添加了一个条件
您可以像这样使用datetime模块来获取当前时间,然后检查时间是否正确,然后运行函数
然后,如果是正确的日期和时间,您可以运行该函数
相关问题 更多 >
编程相关推荐