discord.py事件中的语法无效

时间:2019-12-21 11:50:59

标签: discord.py

import discord
from discord.ext.commands import Bot
from discord.ext import commands+
from discord.utils import get
import time

bot = commands.Bot(command_prefix='r.', description="prefix")


@bot.event
async def on_message_delete(message):
    if(message.author != bot.user):
        else:
                deleted = message.content
                channel = bot.get_channel(657899187957923852)
                await channel.send(time + '"' + deleted + '"')
第12行else:中的

无效的语法(未知,第12行)pylint(语法错误)我试图在不是机器人的消息发送时使用到另一个频道ID等于657899187957923852的频道。

对于导入,我不知道我使用了什么以及此命令所必需的内容(已编辑)

1 个答案:

答案 0 :(得分:0)

您需要在if语句下的代码块中添加一些代码。

@bot.event
async def on_message_delete(message):
    if(message.author != bot.user):
        return 
    else:
        deleted = message.content
        channel = bot.get_channel(657899187957923852)
        await channel.send(time + '"' + deleted + '"')