discord.py

How to make a text reverse using discord.py?


How would one make a text reverse using discord.py?

>Example: >reverse hi

>Output: ih 

Something like that, any clue?


Solution

  • Welcome to stackoverflow! The next time you ask a question, please include code that you have tried. I already have this code, so I'll give this to you and explain in the code comments.

    @client.command()
    async def reverse(ctx, *, arg="A normal sentence"): # if user gives no arg, aka just >reverse
        await ctx.message.delete() # deletes original command message
        await ctx.send(arg[::-1]) # sends the backward sentence, in this case: ecnetnes lamron A