You are not actually using the correct decorators for the on_ready
and on_message
. Any decorator should start with a @, notice how you are only using client.event
instead of @client.event
.
Also make sure to activate some intents for your bot or you will not be able to access some specific information.
intents = discord.Intents.default()
client = commands.Bot(command_prefix = ";", help_command = None, intents = intents)
Your corrected code should be something like this:
import os
from discord.ext import commands
from datetime import datetime
intents = discord.Intents.default()
client = commands.Bot(command_prefix = ";", help_command = None, intents = intents)
dates = datetime.now()
date = datetime.today()
@client.event
async def on_ready():
print("bot is ready")
@client.event
async def on_message(message):
author = message.author
text = message.content
print(author + " said at " + dates + " : " + text)
await client.process_commands(message)
与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…