问题
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