【发布时间】:2022-12-07 15:30:39
【问题描述】:
Discord.Py 机器人将收到消息但不响应
这是我的代码:
import discord
import os
from discord.ext import commands
intents = discord.Intents.default()
client = discord.Client(intents=intents)
@client.event
async def on_ready():
print('We have logged in as {0.user}'.format(client))
@client.event
async def on_message(message):
content = message.content
user = message.author
if user == client.user:
return
print("Received a message:", content)
if content.strip() == "$hello":
await message.channel.send("Hi!")
if content.strip() == "$die":
await message.channel.send("No you")
client.close()
client.run(os.environ['Token'])
我尝试了多种不同形式的代码,但都没有用。
【问题讨论】:
标签: python discord discord.py bots