【发布时间】:2020-03-21 23:40:10
【问题描述】:
我已经尝试了很长时间来添加缺少的参数,但我的尝试都失败了。 我目前Python不太好,代码还没写完,如果我不能很好地解释,请理解。
这是我的错误:
Ignoring exception in on_message
Traceback (most recent call last):
File "C:\Users\...\Programs\Python\Python38-32\lib\site-packages\discord\client.py", line 312, in _run_event
await coro(*args, **kwargs)
TypeError: on_message() missing 1 required positional argument: 'self'
这是我的部分代码:
import asyncio
import discord
from discord import Member
client = discord.Client()
regel_channel_id = someid
class MyClient(discord.Client):
async def on_ready(self):
print('Logged in as')
print(self.user.name)
print(self.user.id)
print('------')
@client.event
async def on_message(message, self):
if '$artikel' in message.content:
await message.channel.send('Question here')
def artikelanswer(m):
return m.author == message.author and m.content.isstring()
try:
Titel = await self.wait_for('message', check=artikelanswer, timeout=10.0)
except asyncio.TimeoutError:
return await message.channel.send('Sorry, you took too long!.')
print(Titel)
client.run("SECRET TOKEN")
我希望您能尽可能简单地解释这个问题。提前谢谢你。
【问题讨论】:
-
只是
on_message(message) -
但是这个命令不起作用?标题 = await self.wait_for('message', check=artikelanswer, timeout=10.0)
-
在你的客户端上使用它
client.wait_for(....discordpy.readthedocs.io/en/latest/…
标签: python message discord.py