Change encode/decode command format

This commit is contained in:
Zeva Rose 2021-06-27 18:57:53 -06:00
parent 9c9e0c7a30
commit bbfdcdc57f

View file

@ -156,30 +156,38 @@ class DevCog(commands.Cog):
if ctx.invoked_subcommand is None:
await ctx.send("Usage: encode <method> <data>")
@_encode.command(name="b64e")
@_encode.command(name="b64")
async def _b64e(self, ctx, *, data: str):
"""Base64 encoding"""
await ctx.send(base64.b64encode(data.encode("UTF-8")).decode("UTF-8"))
@_encode.command(name="b16e")
@_encode.command(name="b16")
async def _b16e(self, ctx, *, data: str):
"""Base16 encoding"""
await ctx.send(base64.b16encode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b16encode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_encode.command(name="b32e")
@_encode.command(name="b32")
async def _b32e(self, ctx, *, data: str):
"""Base32 encoding"""
await ctx.send(base64.b32encode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b32encode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_encode.command(name="a85e")
@_encode.command(name="a85")
async def _a85e(self, ctx, *, data: str):
"""ASCII85 encoding"""
await ctx.send(base64.a85encode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.a85encode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_encode.command(name="b85e")
@_encode.command(name="b85")
async def _b85e(self, ctx, *, data: str):
"""Base85 encoding"""
await ctx.send(base64.b85encode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b85encode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@commands.group()
async def _decode(self, ctx):
@ -187,30 +195,40 @@ class DevCog(commands.Cog):
if ctx.invoked_subcommand is None:
await ctx.send("Usage: decode <method> <data>")
@_decode.command(name="b64d")
@_decode.command(name="b64")
async def _b64d(self, ctx, *, data: str):
"""Base64 decoding"""
await ctx.send(base64.b64decode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b64decode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_decode.command(name="b16d")
@_decode.command(name="b16")
async def _b16d(self, ctx, *, data: str):
"""Base16 decoding"""
await ctx.send(base64.b16decode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b16decode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_decode.command(name="b32d")
@_decode.command(name="b32")
async def _b32d(self, ctx, *, data: str):
"""Base32 decoding"""
await ctx.send(base64.b32decode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b32decode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_decode.command(name="a85d")
@_decode.command(name="a85")
async def _a85d(self, ctx, *, data: str):
"""ASCII85 decoding"""
await ctx.send(base64.a85decode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.a85decode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
@_decode.command(name="b85d")
@_decode.command(name="b85")
async def _b85d(self, ctx, *, data: str):
"""Base85 decoding"""
await ctx.send(base64.b85decode(data.encode("UTF-8")).decode("UTF-8"))
await ctx.send(
"`" + base64.b85decode(data.encode("UTF-8")).decode("UTF-8") + "`"
)
def setup(bot):