Э-э, главная проблема в том, что вы создаете класс MyClient
, но не используете его. Ну, 2 решения:
1. Вы хотите использовать MyClient
класс
. Таким образом, ваш код кода имеет неправильный отступ, вам нужно правильно указать функцию on_message()
.
import asyncio
import discord
from discord import Member
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('------')
async def on_message(self, message):
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 = MyClient()
client.run("SECRET TOKEN")
2. Вы не хотите использовать MyClient
класс
Поэтому вы не должны использовать self
.
import asyncio
import discord
from discord import Member
client = discord.Client()
regel_channel_id = someid
@client.event
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):
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")
Обратите внимание, что вы должны использовать @client.command
декоратор вместо того, чтобы искать команду в сообщении, это было бы очень полезно. Обратите внимание, что я только что помог вам для класса MyClient
(или не использовал его), и ваш код может содержать ошибки.