Making a discord bot that takes a screenshot every 5 minutes and posts it to a specific channel. I'm newer and not really sure what to do next

☆樱花仙子☆ 提交于 2021-01-29 08:08:10

问题


I'm making a discord bot that would take a screenshot of my screen, then post it to discord, and repeat this task every 5 minutes. It seems pretty simple, but I'm pretty new, and have been doing research and not really sure at this point what I've done wrong.

import discord
import pyautogui
import time
import datetime

class MyClient(discord.Client):
    async def on_ready(self):
        print('Logged on as', self.user)
        
    if datetime.datetime.now().minute % 5 == 0: 
        myScreenshot = pyautogui.screenshot()
myScreenshot.save(r'C:\Users\Tyler\Desktop\discord-screenshot-bot-master\screenshot1.png')
channel = client.get_channel(779889991723122708)
channel.send(file=discord.File(r'C:\Users\Tyler\Desktop\discord-screenshot-bot-master\screenshot1.png'))
time.sleep(60)


client = MyClient()
client.run('token')

来源:https://stackoverflow.com/questions/64950684/making-a-discord-bot-that-takes-a-screenshot-every-5-minutes-and-posts-it-to-a-s

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