mirror of https://github.com/stijndcl/didier
Help messages for Fun
parent
5cdb6c3f44
commit
7035f0773f
|
@ -122,8 +122,8 @@ class Currency(commands.Cog):
|
||||||
async def invest(self, ctx: commands.Context, amount: typing.Annotated[typing.Union[str, int], abbreviated_number]):
|
async def invest(self, ctx: commands.Context, amount: typing.Annotated[typing.Union[str, int], abbreviated_number]):
|
||||||
"""Invest `amount` Didier Dinks into your bank.
|
"""Invest `amount` Didier Dinks into your bank.
|
||||||
|
|
||||||
The `amount`-parameter can take both raw numbers, and abbreviations of big numbers. Passing `all` as the
|
The `amount`-argument can take both raw numbers, and abbreviations of big numbers. Additionally, passing
|
||||||
value will invest all of your Didier Dinks.
|
`all` as the value will invest all of your Didier Dinks.
|
||||||
|
|
||||||
Example usage:
|
Example usage:
|
||||||
```
|
```
|
||||||
|
|
|
@ -65,7 +65,7 @@ class Discord(commands.Cog):
|
||||||
async def birthday_set(self, ctx: commands.Context, day: str):
|
async def birthday_set(self, ctx: commands.Context, day: str):
|
||||||
"""Set your birthday to `day`.
|
"""Set your birthday to `day`.
|
||||||
|
|
||||||
Parsing of the `day`-parameter happens in the following order: `DD/MM/YYYY`, `DD/MM/YY`, `DD/MM`.
|
Parsing of the `day`-argument happens in the following order: `DD/MM/YYYY`, `DD/MM/YY`, `DD/MM`.
|
||||||
Other formats will not be accepted.
|
Other formats will not be accepted.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
|
@ -111,7 +111,7 @@ class Discord(commands.Cog):
|
||||||
"""Create a new bookmark for message `message` with label `label`.
|
"""Create a new bookmark for message `message` with label `label`.
|
||||||
|
|
||||||
Instead of the link to a message, you can also reply to the message you wish to bookmark. In this case,
|
Instead of the link to a message, you can also reply to the message you wish to bookmark. In this case,
|
||||||
the `message`-parameter can be left out.
|
the `message`-argument can be left out.
|
||||||
|
|
||||||
`label` can not be names (or aliases) of subcommands.
|
`label` can not be names (or aliases) of subcommands.
|
||||||
"""
|
"""
|
||||||
|
@ -204,7 +204,7 @@ class Discord(commands.Cog):
|
||||||
"""Pin `message` in the current channel.
|
"""Pin `message` in the current channel.
|
||||||
|
|
||||||
Instead of the link to a message, you can also reply to the message you wish to pin. In this case,
|
Instead of the link to a message, you can also reply to the message you wish to pin. In this case,
|
||||||
the `message`-parameter can be left out.
|
the `message`-argument can be left out.
|
||||||
"""
|
"""
|
||||||
# If no message was passed, allow replying to the message that should be pinned
|
# If no message was passed, allow replying to the message that should be pinned
|
||||||
if message is None and ctx.message.reference is not None:
|
if message is None and ctx.message.reference is not None:
|
||||||
|
|
|
@ -18,7 +18,7 @@ class Fun(commands.Cog):
|
||||||
client: Didier
|
client: Didier
|
||||||
|
|
||||||
# Slash groups
|
# Slash groups
|
||||||
memes_slash = app_commands.Group(name="meme", description="Commands to generate memes", guild_only=False)
|
memes_slash = app_commands.Group(name="meme", description="Commands to generate memes.", guild_only=False)
|
||||||
|
|
||||||
def __init__(self, client: Didier):
|
def __init__(self, client: Didier):
|
||||||
self.client = client
|
self.client = client
|
||||||
|
@ -32,56 +32,61 @@ class Fun(commands.Cog):
|
||||||
@commands.hybrid_command(
|
@commands.hybrid_command(
|
||||||
name="dadjoke",
|
name="dadjoke",
|
||||||
aliases=["dad", "dj"],
|
aliases=["dad", "dj"],
|
||||||
description="Why does Yoda's code always crash? Because there is no try.",
|
|
||||||
)
|
)
|
||||||
async def dad_joke(self, ctx: commands.Context):
|
async def dad_joke(self, ctx: commands.Context):
|
||||||
"""Get a random dad joke"""
|
"""Why does Yoda's code always crash? Because there is no try."""
|
||||||
async with self.client.postgres_session as session:
|
async with self.client.postgres_session as session:
|
||||||
joke = await get_random_dad_joke(session)
|
joke = await get_random_dad_joke(session)
|
||||||
return await ctx.reply(joke.joke, mention_author=False)
|
return await ctx.reply(joke.joke, mention_author=False)
|
||||||
|
|
||||||
@commands.group(name="memegen", aliases=["meme", "memes"], invoke_without_command=True, case_insensitive=True)
|
@commands.group(name="memegen", aliases=["meme", "memes"], invoke_without_command=True, case_insensitive=True)
|
||||||
async def memegen_msg(self, ctx: commands.Context, meme_name: str, *, fields: str):
|
async def memegen_msg(self, ctx: commands.Context, template: str, *, fields: str):
|
||||||
"""Command group for meme-related commands"""
|
"""Generate a meme with template `template` and fields `fields`.
|
||||||
|
|
||||||
|
The arguments are parsed based on spaces. Arguments that contain spaces should be wrapped in "quotes".
|
||||||
|
|
||||||
|
Example: `memegen a b c d` will be parsed as `template: "a"`, `fields: ["b", "c", "d"]`
|
||||||
|
|
||||||
|
Example: `memegen "a b" "c d"` will be parsed as `template: "a b"`, `fields: ["c d"]`
|
||||||
|
"""
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
meme = await self._do_generate_meme(meme_name, shlex.split(fields))
|
meme = await self._do_generate_meme(template, shlex.split(fields))
|
||||||
return await ctx.reply(meme, mention_author=False)
|
return await ctx.reply(meme, mention_author=False)
|
||||||
|
|
||||||
@memegen_msg.command(name="preview", aliases=["p"])
|
@memegen_msg.command(name="preview", aliases=["p"])
|
||||||
async def memegen_preview_msg(self, ctx: commands.Context, meme_name: str):
|
async def memegen_preview_msg(self, ctx: commands.Context, template: str):
|
||||||
"""Generate a preview for a meme, to see how the fields are structured"""
|
"""Generate a preview for the meme template `template`, to see how the fields are structured."""
|
||||||
async with ctx.typing():
|
async with ctx.typing():
|
||||||
fields = [f"Field #{i + 1}" for i in range(20)]
|
fields = [f"Field #{i + 1}" for i in range(20)]
|
||||||
meme = await self._do_generate_meme(meme_name, fields)
|
meme = await self._do_generate_meme(template, fields)
|
||||||
return await ctx.reply(meme, mention_author=False)
|
return await ctx.reply(meme, mention_author=False)
|
||||||
|
|
||||||
@memes_slash.command(name="generate", description="Generate a meme")
|
@memes_slash.command(name="generate")
|
||||||
async def memegen_slash(self, interaction: discord.Interaction, meme: str):
|
async def memegen_slash(self, interaction: discord.Interaction, template: str):
|
||||||
"""Slash command to generate a meme"""
|
"""Generate a meme with template `template`."""
|
||||||
async with self.client.postgres_session as session:
|
async with self.client.postgres_session as session:
|
||||||
result = expect(await get_meme_by_name(session, meme), entity_type="meme", argument=meme)
|
result = expect(await get_meme_by_name(session, template), entity_type="meme", argument=template)
|
||||||
|
|
||||||
modal = GenerateMeme(self.client, result)
|
modal = GenerateMeme(self.client, result)
|
||||||
await interaction.response.send_modal(modal)
|
await interaction.response.send_modal(modal)
|
||||||
|
|
||||||
@memes_slash.command(
|
@memes_slash.command(name="preview")
|
||||||
name="preview", description="Generate a preview for a meme, to see how the fields are structured"
|
@app_commands.describe(template="The meme template to use in the preview.")
|
||||||
)
|
async def memegen_preview_slash(self, interaction: discord.Interaction, template: str):
|
||||||
async def memegen_preview_slash(self, interaction: discord.Interaction, meme: str):
|
"""Generate a preview for a meme, to see how the fields are structured."""
|
||||||
"""Slash command to generate a meme preview"""
|
|
||||||
await interaction.response.defer()
|
await interaction.response.defer()
|
||||||
|
|
||||||
fields = [f"Field #{i + 1}" for i in range(20)]
|
fields = [f"Field #{i + 1}" for i in range(20)]
|
||||||
meme_url = await self._do_generate_meme(meme, fields)
|
meme_url = await self._do_generate_meme(template, fields)
|
||||||
|
|
||||||
await interaction.followup.send(meme_url, ephemeral=True)
|
await interaction.followup.send(meme_url, ephemeral=True)
|
||||||
|
|
||||||
@memegen_slash.autocomplete("meme")
|
@memegen_slash.autocomplete("template")
|
||||||
@memegen_preview_slash.autocomplete("meme")
|
@memegen_preview_slash.autocomplete("template")
|
||||||
async def _memegen_slash_autocomplete_meme(
|
async def _memegen_slash_autocomplete_template(
|
||||||
self, _: discord.Interaction, current: str
|
self, _: discord.Interaction, current: str
|
||||||
) -> list[app_commands.Choice[str]]:
|
) -> list[app_commands.Choice[str]]:
|
||||||
"""Autocompletion for the 'meme'-parameter"""
|
"""Autocompletion for the 'template'-parameter"""
|
||||||
return self.client.database_caches.memes.get_autocomplete_suggestions(current)
|
return self.client.database_caches.memes.get_autocomplete_suggestions(current)
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue