-
-
Notifications
You must be signed in to change notification settings - Fork 240
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Add a few cases commands to fun.py to output a string in a specific case. #1455
Changes from 5 commits
90625a1
494f7c8
54a4622
a03b682
7bb7be4
d701255
1a4bc6a
731ab4d
ddaeb14
7ea86c9
1891f44
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change | ||||
---|---|---|---|---|---|---|
|
@@ -80,6 +80,90 @@ def conversion_func(text: str) -> str: | |||||
converted_text = f">>> {converted_text.lstrip('> ')}" | ||||||
await ctx.send(content=converted_text, embed=embed) | ||||||
|
||||||
@commands.command(name="snakecase", aliases=("scase",)) | ||||||
async def snakecase_command(self, ctx: Context, *, text: str | None) -> None: | ||||||
"""Attempts to convert the provided string to snake_case.""" | ||||||
text = helpers.neutralise_string(text) | ||||||
def conversion_func(text: str) -> str: | ||||||
"""Converts the provided string to snake_case.""" | ||||||
return "_".join( | ||||||
text.split() | ||||||
) | ||||||
text = await clean_text_or_reply(ctx, text) | ||||||
text, embed = await messages.get_text_and_embed(ctx, text) | ||||||
# Convert embed if it exists | ||||||
if embed is not None: | ||||||
embed = messages.convert_embed(conversion_func, embed) | ||||||
converted_text = conversion_func(text) | ||||||
converted_text = helpers.suppress_links(converted_text) | ||||||
# Don't put >>> if only embed present | ||||||
if converted_text: | ||||||
converted_text = f">>> {converted_text.lstrip('> ')}" | ||||||
await ctx.send(content=converted_text, embed=embed) | ||||||
|
||||||
@commands.command(name="pascalcase", aliases=("pcase", "pascal",)) | ||||||
async def pascalcase_command(self, ctx: Context, *, text: str | None) -> None: | ||||||
"""Attempts to convert the provided string to pascalCase.""" | ||||||
text = helpers.neutralise_string(text) | ||||||
def conversion_func(text: str) -> str: | ||||||
"""Converts the provided string to pascalCase.""" | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same note here for the docstring about the pascal & camel case notation |
||||||
return "".join( | ||||||
word[0].upper()+word[1:] if i != 0 else word for i, word in enumerate(text.split()) | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. same thing about the usage of |
||||||
) | ||||||
text = await clean_text_or_reply(ctx, text) | ||||||
text, embed = await messages.get_text_and_embed(ctx, text) | ||||||
# Convert embed if it exists | ||||||
if embed is not None: | ||||||
embed = messages.convert_embed(conversion_func, embed) | ||||||
converted_text = conversion_func(text) | ||||||
converted_text = helpers.suppress_links(converted_text) | ||||||
# Don't put >>> if only embed present | ||||||
if converted_text: | ||||||
converted_text = f">>> {converted_text.lstrip('> ')}" | ||||||
await ctx.send(content=converted_text, embed=embed) | ||||||
|
||||||
@commands.command(name="screamingsnakecase", aliases=("screamsnake", "ssnake", "screamingsnake",)) | ||||||
async def screamingsnakecase_command(self, ctx: Context, *, text: str | None) -> None: | ||||||
"""Attempts to convert the provided string to SCREAMING_SNAKE_CASE.""" | ||||||
shtlrs marked this conversation as resolved.
Show resolved
Hide resolved
|
||||||
text = helpers.neutralise_string(text) | ||||||
def conversion_func(text: str) -> str: | ||||||
"""Converts the provided string to SCREAMING_SNAKE_CASE.""" | ||||||
return "_".join( | ||||||
word.upper() for word in text.split() | ||||||
) | ||||||
text = await clean_text_or_reply(ctx, text) | ||||||
text, embed = await messages.get_text_and_embed(ctx, text) | ||||||
# Convert embed if it exists | ||||||
if embed is not None: | ||||||
embed = messages.convert_embed(conversion_func, embed) | ||||||
converted_text = conversion_func(text) | ||||||
converted_text = helpers.suppress_links(converted_text) | ||||||
# Don't put >>> if only embed present | ||||||
if converted_text: | ||||||
converted_text = f">>> {converted_text.lstrip('> ')}" | ||||||
await ctx.send(content=converted_text, embed=embed) | ||||||
|
||||||
@commands.command(name="camelcase", aliases=("ccase", "camel",)) | ||||||
async def camelcase_command(self, ctx: Context, *, text: str | None) -> None: | ||||||
"""Attempts to convert the provided string to CamelCase.""" | ||||||
text = helpers.neutralise_string(text) | ||||||
def conversion_func(text: str) -> str: | ||||||
"""Converts the provided string to CamelCase.""" | ||||||
return "".join( | ||||||
word[0].upper()+word[1:] for word in text.split() | ||||||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There's a native way of doing this
Suggested change
|
||||||
) | ||||||
text = await clean_text_or_reply(ctx, text) | ||||||
text, embed = await messages.get_text_and_embed(ctx, text) | ||||||
# Convert embed if it exists | ||||||
if embed is not None: | ||||||
embed = messages.convert_embed(conversion_func, embed) | ||||||
converted_text = conversion_func(text) | ||||||
converted_text = helpers.suppress_links(converted_text) | ||||||
# Don't put >>> if only embed present | ||||||
if converted_text: | ||||||
converted_text = f">>> {converted_text.lstrip('> ')}" | ||||||
await ctx.send(content=converted_text, embed=embed) | ||||||
|
||||||
@commands.group(name="caesarcipher", aliases=("caesar", "cc",)) | ||||||
async def caesarcipher_group(self, ctx: Context) -> None: | ||||||
""" | ||||||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
If i'm not mistaken, it's the other way around where
PascalCase
should bepascalCase
andCamelCase
should becamelCase
So both docstrings & conversion functions need to be switched
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Cant believe I had them the wrong way around hey. Fixed in both files now xD