Skip to content

Commit 6d2d531

Browse files
committed
fix: Made the commands more descriptive
1 parent 3853868 commit 6d2d531

File tree

1 file changed

+35
-20
lines changed

1 file changed

+35
-20
lines changed

tux/cogs/utility/encode_decode.py

Lines changed: 35 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import base64
22
import binascii
33

4-
from discord import AllowedMentions
4+
from discord import AllowedMentions, app_commands
55
from discord.ext import commands
66

77
from tux.bot import Tux
@@ -44,16 +44,23 @@ async def send_message(self, ctx: commands.Context[Tux], data: str):
4444
await ctx.reply(
4545
content=data,
4646
allowed_mentions=allowed_mentions,
47-
ephemeral=False,
47+
ephemeral=True,
4848
)
4949

50-
@commands.hybrid_command(
51-
name="encode",
50+
@commands.hybrid_command(name="encode", aliases=["ec"], description="Encode a message")
51+
@app_commands.describe(text="Text to encode")
52+
@app_commands.choices(
53+
codesystem=[
54+
app_commands.Choice(name="base16", value="base16"),
55+
app_commands.Choice(name="base32", value="base32"),
56+
app_commands.Choice(name="base64", value="base64"),
57+
app_commands.Choice(name="base85", value="base85"),
58+
],
5259
)
5360
async def encode(
5461
self,
5562
ctx: commands.Context[Tux],
56-
cs: str,
63+
codesystem: str,
5764
*,
5865
text: str,
5966
) -> None:
@@ -64,23 +71,23 @@ async def encode(
6471
----------
6572
ctx : commands.Context[Tux]
6673
The context of the command.
67-
cs : str
74+
codesystem : str
6875
The coding system.
6976
text : str
7077
The text you want to encode.
7178
"""
7279

73-
cs = cs.lower()
80+
codesystem = codesystem.lower()
7481
btext = text.encode(encoding="utf-8")
7582

7683
try:
77-
if cs == "base16":
84+
if codesystem == "base16":
7885
data = base64.b16encode(btext)
79-
elif cs == "base32":
86+
elif codesystem == "base32":
8087
data = base64.b32encode(btext)
81-
elif cs == "base64":
88+
elif codesystem == "base64":
8289
data = base64.b64encode(btext)
83-
elif cs == "base85":
90+
elif codesystem == "base85":
8491
data = base64.b85encode(btext)
8592
else:
8693
await ctx.reply(
@@ -98,13 +105,21 @@ async def encode(
98105
ephemeral=True,
99106
)
100107

101-
@commands.hybrid_command(
102-
name="decode",
108+
@commands.hybrid_command(name="decode", aliases=["dc"], description="Decode a message")
109+
@app_commands.describe(codesystem="Which Coding System to use")
110+
@app_commands.describe(text="Text to decode")
111+
@app_commands.choices(
112+
codesystem=[
113+
app_commands.Choice(name="base16", value="base16"),
114+
app_commands.Choice(name="base32", value="base32"),
115+
app_commands.Choice(name="base64", value="base64"),
116+
app_commands.Choice(name="base85", value="base85"),
117+
],
103118
)
104119
async def decode(
105120
self,
106121
ctx: commands.Context[Tux],
107-
cs: str,
122+
codesystem: str,
108123
*,
109124
text: str,
110125
) -> None:
@@ -115,23 +130,23 @@ async def decode(
115130
----------
116131
ctx : commands.Context[Tux]
117132
The context of the command.
118-
cs : str
133+
codesystem : str
119134
The coding system.
120135
text : str
121136
The text you want to decode.
122137
"""
123138

124-
cs = cs.lower()
139+
codesystem = codesystem.lower()
125140
btext = text.encode(encoding="utf-8")
126141

127142
try:
128-
if cs == "base16":
143+
if codesystem == "base16":
129144
data = base64.b16decode(btext)
130-
elif cs == "base32":
145+
elif codesystem == "base32":
131146
data = base64.b32decode(btext)
132-
elif cs == "base64":
147+
elif codesystem == "base64":
133148
data = base64.b64decode(btext)
134-
elif cs == "base85":
149+
elif codesystem == "base85":
135150
data = base64.b85decode(btext)
136151
else:
137152
await ctx.reply(

0 commit comments

Comments
 (0)