Discord bot in disnake library

46 Views Asked by At

The code should issue a varna to the user and report it to the chat and indicate the beginning and end of the warn.

@commands.has_permissions(administrator=True)
@bot.slash_command()
async def warn(inter, 
               member: disnake.Member = commands.Param(name='пользователь', description='укажите пользователя'),
               reason: str = commands.Param(name='причина', description='укажите причину', default='Нарушение правил сервера')):
    if member.top_role > inter.author.top_role:
        await inter.send(embed=disnake.Embed(
            description=f"{member.mention} имеет прав больше Вы!",
            color= 0x2c0bd4 ))
    timenewWARN = int(datetime.now().timestamp())
    date_1 = (datetime.strptime(timenewWARN, "%m/%d/%y"))
    timeendWARN= date_1 + datetime.timedelta(days=10)
    await inter.send(embed=disnake.Embed(
        description=f"{inter.author.mention} выдал предупреждение пользователю {member.mention}\nДата выдачи варна: <t:{timenewWARN}:f>\nДата снятия варна: <t:{timeendWARN}:f>\nПричина: {reason}",
        color = 0xeb0c0c))
    await member.warn(reason=reason)

When executing the code, it throws an error: disnake.ext.commands.errors.CommandInvokeError: Command raised an exception: TypeError: strptime() argument 1 must be str, not int

What needs to be changed in the code?

Tried changing the line: date_1 = (datetime.strptime(str(timenewWARN, "%m/%d/%y")), but it gives an error with bytes.

0

There are 0 best solutions below