【发布时间】:2021-04-27 15:30:23
【问题描述】:
from discord.ext import commands, tasks
class sendmessage10seconds(commands.Cog):
def __init__(self, client):
self.client = client
print("Cog is running")
@tasks.loop(seconds=10)
async def sendmessage(ctx, self):
channel = self.get_channel(802273252973477960)
await channel.send("Hi")
sendmessage.start()
def setup(client):
client.add_cog(sendmessage10seconds(client))
到目前为止,这是我的代码。当我运行它时,我得到了这个错误:
Traceback (most recent call last):
File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/ext/tasks/__init__.py", line 101, in _loop
await self.coro(*args, **kwargs)
TypeError: sendmessage() missing 2 required positional arguments: 'ctx' and 'self'
我做错了什么?
【问题讨论】:
标签: python python-3.x discord.py discord.py-rewrite python-3.8