Ответьте на команду discord.py

Я сделал бота, и когда кто-то спрашивает его о чем-то с помощью команды, он должен отвечать, но не работает. В нем говорится, что это ошибка атрибута и что у класса «Client» нет атрибута «send_message».

infos\main.py 
Logged in as
Beylogger
584809202523045889
------
['Type: Défense\n', 'Coup Spécial: ???\n', 'Utilité: Défense et endurance\n', 'Blader: Wakiya Murasaki\n', 'Disque: Armed\n', 'Pointe: Massive\n', 'Évolutions: Wild, Tornado\n', 'Date de sortie: 19 septembre 2015\n', 'Globalement: Excellente toupie pour sa génération']
Ignoring exception in on_message
Traceback (most recent call last):
  File "C:\Users\waabe\AppData\Local\Programs\Python\Python36-32\lib\site-packages\discord\client.py", line 251, in _run_event
    await coro(*args, **kwargs)
  File "C:\Users\waabe\AppData\Local\Programs\Python\Python36-32\beycommunity\infos\main.py", line 22, in on_message
    await discord.Client().send_message(message.channel, dex.format(author))
AttributeError: 'Client' object has no attribute 'send_message'
import discord
import sys
import os

TOKEN = 'I will not show it'

client = discord.Client()

@client.event
async def on_message(message):
    # we do not want the bot to reply to itself
    if message.author == client.user:
        return

    if message.content.startswith('bey!'):
        channel = client.get_channel("ID")
        message_real=(message.content).split("!")
        bey_name=message_real[1]
        where=bey_name+".txt"
        dex=open(where,"r").readlines()
        print(dex)
        await discord.Client().send_message(message.channel, dex.format(author))

@client.event
async def on_ready():
    print('Logged in as')
    print(client.user.name)
    print(client.user.id)
    print('------')

client.run(TOKEN)

person Waaberi Ibrahim    schedule 08.06.2019    source источник


Ответы (1)


Вам необходимо использовать send, который вызывается TextChannel объект.

await message.channel.send("Some text")
person BrainDead    schedule 09.06.2019