我正在尝试访问消息的内容并使用discord.py打印它。问题是,无论什么情况,内容都是空的。代码工作在我的笔记本电脑,但只是拒绝在这台电脑上工作。在尝试运行其他在其他设备上工作的更复杂的代码时,也已经发生了同样的情况。没有出现错误。
import nest_asyncio
nest_asyncio.apply()
import discord
TOKEN = "TOKEN"
client = discord.Client(intents=discord.Intents.default())
@client.event
async def on_ready():
print("logged in as {0.user}".format(client))
@client.event
async def on_message(message):
username = str(message.author).split("#")[0]
user_message = message.content
channel = str(message.channel.name)
print(f"{username}: {user_message} ({channel})")
client.run(TOKEN)发布于 2022-09-25 12:00:58
https://stackoverflow.com/questions/73844081
复制相似问题