首页 > 解决方案 > discord.ext.commands.errors.CommandInvokeError:命令引发异常:AttributeError:'Command'对象没有属性'strftime'

问题描述

我试图制作一个机器人命令,您可以在其中询问机器人是否是星期三,但我不断收到此错误,我不知道该怎么做。请帮忙。这是我的代码:

@client.command(aliases=['wednesdaymydudes', 'wednesday', 'wednesdaycheck'],
                pass_context=True)
async def isitwednesdaymydudes(ctx):
    currentday = time.strftime('%A')
    if currentday == 'Wednesday':
        await ctx.send('It is Wednesday, {}'.format(ctx.message.author.mention))
    else:
        await ctx.send('It is not Wednesday, {}'.format(ctx.message.author.mention))

标签: pythondiscord.pydiscord.py-rewrite

解决方案


为了获得星期几,你应该做的是

from datetime import datetime as dt

day = dt.now()

day_of_week = day.strftime('%A')

推荐阅读