我正在制作一個不和諧的機器人,但遇到了機器人無法啟動的問題,如果您能幫助我,我將不勝感激)。該機器人是在 python 中創建的
# -*- coding: utf-8 -*-
import discord
from discord.ext import commands
from config import token
import youtube_dl
import os
bot = commands.Bot(command_prefix='!')
@bot.event
async def on_ready():
print('bot online!')
@bot.event()
async def on_message():
print('New Message!')
bot.run(token)
uj5u.com熱心網友回復:
您應該@bot.event為事件使用裝飾器。不是@bot.event()。
同時on_message功能應該有1個說法。所以,你需要寫`
@bot.event
async def on_message(message):
pass # whatever here
轉載請註明出處,本文鏈接:https://www.uj5u.com/caozuo/371025.html
