Как я могу исправить "Bot" объект не имеет атрибута "send_message" на Python 3.6.1? - PullRequest
0 голосов
/ 15 мая 2019

Итак, я программировал бота на 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'
...