我正在尝试制作一个每 15 分钟发送一条随机消息的机器人。机器人加载没有问题,但没有发送消息,我是否遗漏了什么?
import discord
import asyncio
import random
from discord.ext import commands, tasks
client = discord.Client()
token = 'xxx'
@tasks.loop(seconds=5)
async def background_loop():
await client.wait_until_ready()
while not client.is_closed:
channel = client.get_channel(xxx)
messages = ["Hello!", "How are you doing?", "Howdy!"]
await channel.send(random.choice(messages))
background_loop.start()
@client.event
async def on_ready():
print('Logged in as')
print(client.user.name)
print(client.user.id)
print('------')
client.run(token)
Qyouu
相关分类