消息侦听器无法正常工作 discord.py bot

时间:2021-05-10 17:28:54

标签: python discord discord.py bots

我正在制作一个机器人,而我使用的消息侦听器并未接收其他人的消息:

@bot.event
async def on_message(message):
  chnl = message.channel.name
  ts = time.time()
  athr = message.author.display_name
  st = datetime.fromtimestamp(ts).strftime('%Y-%m-%d %H:%M:%S')
  
  
  with open("logs/chat.txt", "a") as text_file:
    #print(f"<{message.created_at} | {athr}> {message}", file=text_file)
    print(f"_(#{chnl}) <{st} | {athr}> {message.content}", file=text_file)
    return athr, st, message.content
  await bot.process_commands(message)

这似乎是一个简单的问题,但我不明白有什么问题。


load_dotenv()
TOKEN = os.getenv("DISCORD_TOKEN")
GUILD = os.getenv("DISCORD_GUILD")


bot = commands.Bot(command_prefix=';')

0 个答案:

没有答案