File tree 1 file changed +26
-2
lines changed
1 file changed +26
-2
lines changed Original file line number Diff line number Diff line change @@ -20,8 +20,32 @@ async def snippet_cmd(self, ctx: GuildContext):
20
20
21
21
@commands .guild_only ()
22
22
@snippet_cmd .command ()
23
- async def remove (self , ctx , * args ):
24
- await ctx .send ("placeholder for snippet remove" )
23
+ async def remove (self , ctx : GuildContext , name : str ):
24
+ query = """
25
+ DELETE FROM snippets
26
+ WHERE guild_id = $1 AND name = $2
27
+ RETURNING name
28
+ """
29
+ result = await self ._bot .pool .fetchrow (query , ctx .guild .id , name )
30
+ if result is None :
31
+ await ctx .reply (
32
+ embed = discord .Embed (
33
+ title = "Deletion failed" ,
34
+ colour = discord .Colour .red (),
35
+ description = f"Snippet `{ name } ` was not found and "
36
+ + "hence was not deleted." ,
37
+ ),
38
+ ephemeral = True ,
39
+ )
40
+ else :
41
+ await ctx .reply (
42
+ embed = discord .Embed (
43
+ title = "Deletion successful" ,
44
+ colour = discord .Colour .green (),
45
+ description = f"Snippet `{ name } ` was deleted successfully" ,
46
+ ),
47
+ ephemeral = True ,
48
+ )
25
49
26
50
@commands .guild_only ()
27
51
@snippet_cmd .command ()
You can’t perform that action at this time.
0 commit comments