@@ -1727,14 +1727,30 @@ async def autotrigger_add(self, ctx, keyword, *, command):
17271727 description = f"Another autotrigger with the same name already exists: `{ keyword } `." ,
17281728 )
17291729 else :
1730- self .bot .auto_triggers [keyword ] = command
1731- await self .bot .config .update ()
1730+ # command validation
1731+ valid = False
1732+ split_cmd = command .split (" " )
1733+ for n in range (1 , len (split_cmd ) + 1 ):
1734+ if self .bot .get_command (" " .join (split_cmd [0 :n ])):
1735+ print (self .bot .get_command (" " .join (split_cmd [0 :n ])))
1736+ valid = True
1737+ break
1738+
1739+ if valid :
1740+ self .bot .auto_triggers [keyword ] = command
1741+ await self .bot .config .update ()
17321742
1733- embed = discord .Embed (
1734- title = "Success" ,
1735- color = self .bot .main_color ,
1736- description = f"Keyword `{ keyword } ` has been linked to `{ command } `." ,
1737- )
1743+ embed = discord .Embed (
1744+ title = "Success" ,
1745+ color = self .bot .main_color ,
1746+ description = f"Keyword `{ keyword } ` has been linked to `{ command } `." ,
1747+ )
1748+ else :
1749+ embed = discord .Embed (
1750+ title = "Error" ,
1751+ color = self .bot .error_color ,
1752+ description = "Invalid command. Note that autotriggers do not work with aliases." ,
1753+ )
17381754
17391755 await ctx .send (embed = embed )
17401756
@@ -1747,14 +1763,30 @@ async def autotrigger_edit(self, ctx, keyword, *, command):
17471763 keyword , self .bot .auto_triggers .keys (), "Autotrigger"
17481764 )
17491765 else :
1750- self .bot .auto_triggers [keyword ] = command
1751- await self .bot .config .update ()
1766+ # command validation
1767+ valid = False
1768+ split_cmd = command .split (" " )
1769+ for n in range (1 , len (split_cmd ) + 1 ):
1770+ if self .bot .get_command (" " .join (split_cmd [0 :n ])):
1771+ print (self .bot .get_command (" " .join (split_cmd [0 :n ])))
1772+ valid = True
1773+ break
1774+
1775+ if valid :
1776+ self .bot .auto_triggers [keyword ] = command
1777+ await self .bot .config .update ()
17521778
1753- embed = discord .Embed (
1754- title = "Success" ,
1755- color = self .bot .main_color ,
1756- description = f"Keyword `{ keyword } ` has been linked to `{ command } `." ,
1757- )
1779+ embed = discord .Embed (
1780+ title = "Success" ,
1781+ color = self .bot .main_color ,
1782+ description = f"Keyword `{ keyword } ` has been linked to `{ command } `." ,
1783+ )
1784+ else :
1785+ embed = discord .Embed (
1786+ title = "Error" ,
1787+ color = self .bot .error_color ,
1788+ description = "Invalid command. Note that autotriggers do not work with aliases." ,
1789+ )
17581790
17591791 await ctx .send (embed = embed )
17601792
0 commit comments