Discord.py Schedule

元气小坏坏 提交于 2019-12-24 10:38:21

问题


This is what I have so far... is does work for the amount delay seconds I want, but how to I add the time module or shedule module to make it work.. Just in case I want the bot to send the message every 24hrs

import discord
import asyncio
from discord.ext import commands
import schedule
import time

TOKEN = 'xxxxx'

client = commands.Bot(command_prefix = '.')

channel_id = '515994xxxxx5036697'

@client.event
async def on_ready():
    print('Bot Online.')

async def alarm_message():
    await client.wait_until_ready()
    while not client.is_closed:
        channel = client.get_channel(channel_id)
        messages = ('test')
        await client.send_message(channel, messages)
        await asyncio.sleep(5) #runs every 5 seconds

client.loop.create_task(alarm_message())

client.run(TOKEN)

来源:https://stackoverflow.com/questions/53662781/discord-py-schedule

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!