我正在尝试制作一个不和谐的机器人,当我在本地运行它时,它工作得很好;但是,当我将其推送到 heroku 时,它不起作用,因为由于某种原因,每条消息的 message.content 都是空的。前几天还好好的,现在就坏了。
main.py代码:
@client.event
async def on_message(message):
msg = message.content
print(f'msg1: {msg}')
print(f'msg: {message}')
if message.author == client.user:
return
if message.content == '':
await message.channel.send('test')
需求.txt:
git+https://github.com/Rapptz/discord.py
dnspython==2.2.1
async-timeout==4.0.2
gspread==5.3.0
oauth2client==4.1.3
openpyxl==3.0.9
discord==1.7.3
转到开发门户并打开意图 然后在创建机器人时添加
import discord
from discord.ext import commands
client = commands.Bot(command_prefix=">", intents=discord.Intents.all())]
@client.event
async def on_message(message):
if message.author.bot:
pass
else:
print(message.content)
client.run("token")
应该可以工作
导入不和谐
客户端 = discord.Client(intents=discord.Intents.all())