我制造了一个机器人,当有人用命令向他询问某事时,它应该响应,但不起作用。 它说这是一个属性错误,并且“ 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)