如何在python 3.6.1上修复“属性”对象没有属性“ send_message”?

时间:2019-05-15 18:22:37

标签: python python-3.x discord discord.py

因此,我一直在repl.it python 3.6.1上编写机器人程序,但遇到了问题。问题是,在我与僵尸网络建立连接后,我键入一个单词(cookie),这将使僵尸网络在僵尸服务器上执行操作。我正在使用的代码如下。以及错误代码

我的代码:

import discord
from discord.ext.commands import Bot
from discord.ext import commands
import asyncio
import time

TimeoutError

Client = discord.Client() #Initialise Client 
client = commands.Bot(command_prefix = "?") #Initialise client bot


@client.event 
async def on_ready():
print("Bot is online and connected to Discord") #This will be called
# when the bot connects to the server

@client.event
async def on_message(message):
    if message.content == "cookie":
        await client.send_message(message.channel, "cookie")


client.run("my discord bot token")

终端中的错误:

Ignoring exception in on_message
Traceback (most recent call last):
  File "/home/runner/.local/lib/python3.6/site-packages/discord/client.py", line 251, in _run_event
    await coro(*args, **kwargs)
  File "main.py", line 20, in on_message
    await client.send_message(message.channel, "cookie")
AttributeError: 'Bot' object has no attribute 'send_message'

0 个答案:

没有答案