因此,我一直在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'