我不太擅长编程,无法让它发挥作用 我收到错误“'客户端'对象没有属性'send_message'” 我不知道如何修复它,但 StackOverflow 让我输入更多的东西 我确实安装了 discord.py 我看过很多关于这个的页面 我真的不知道该听什么
import discord
from discord.ext import commands
import random
client = discord.Client()
@client.event
async def on_ready():
print('bot is ready')
@client.event
async def on_message(message):
i = random.randint(0,30)
elif i == 4:
await client.send_message(message.channel, 'msg')
elif i == 3:
await client.send_message(message.channel, 'msg')
elif i == 2:
await client.send_message(message.channel, 'msg')
elif i == 1:
await client.send_message(message.channel, 'msg')
elif i == 6:
await client.send_message(message.channel, 'msg')
elif i == 7:
await client.send_message(message.channel, 'msg')
elif i == 8:
await client.send_message(message.channel, 'msg')
elif i == 9:
await client.send_message(message.channel, 'msg')
elif i == 10:
await client.send_message(message.channel, 'msg')
elif i == 11:
await client.send_message(message.channel, 'msg')
elif i == 12:
await client.send_message(message.channel, 'msg')
elif i == 14:
await client.send_message(message.channel, 'msg')
elif i == 15:
await client.send_message(message.channel, 'msg')
elif i == 16:
await client.send_message(message.channel, 'msg')
elif i == 17:
await client.send_message(message.channel, 'msg')
elif i == 18:
await client.send_message(message.channel, 'msg')
elif i == 19:
await client.send_message(message.channel, 'msg')
elif i == 20:
await client.send_message(message.channel, 'msg')
elif i == 21:
await client.send_message(message.channel, 'msg')
elif i == 22:
await client.send_message(message.channel, 'msg')
elif i == 24:
await client.send_message(message.channel, 'msg')
elif i == 25:
await client.send_message(message.channel, 'msg')
elif i == 26:
await client.send_message('msg')
await client.process_commands(message)
client.run('TOKEN')
答案 0 :(得分:0)
使用 await message.channel.send
而不是 await client.send_message