|
| 1 | +import discord |
1 | 2 | from discord.ext import commands
|
2 | 3 | from libs.utils import GuildContext
|
3 | 4 | from rodhaj import Rodhaj
|
@@ -29,8 +30,28 @@ async def new(self, ctx, *args):
|
29 | 30 |
|
30 | 31 | @commands.guild_only()
|
31 | 32 | @snippet_cmd.command()
|
32 |
| - async def show(self, ctx, *args): |
33 |
| - await ctx.send("placeholder for snippet show") |
| 33 | + async def show(self, ctx: GuildContext, name: str): |
| 34 | + query = """ |
| 35 | + SELECT content FROM snippets |
| 36 | + WHERE guild_id = $1 AND name = $2 |
| 37 | + """ |
| 38 | + data = await self._bot.pool.fetchrow(query, ctx.guild.id, name) |
| 39 | + if data is None: |
| 40 | + ret_embed = discord.Embed( |
| 41 | + title="Oops...", |
| 42 | + colour=discord.Colour.red(), |
| 43 | + description=f"The snippet `{name}` was not found. " |
| 44 | + + "To create a new snippet with this name, " |
| 45 | + + f"please run `snippet create {name} <content>`", |
| 46 | + ) |
| 47 | + await ctx.reply(embed=ret_embed, ephemeral=True) |
| 48 | + else: |
| 49 | + ret_data = discord.Embed( |
| 50 | + title=f"Snippet information for `{name}`", |
| 51 | + colour=discord.Colour.green(), |
| 52 | + description=data[0], |
| 53 | + ) |
| 54 | + await ctx.reply(embed=ret_data, ephemeral=True) |
34 | 55 |
|
35 | 56 | @commands.guild_only()
|
36 | 57 | @snippet_cmd.command()
|
|
0 commit comments