Hi,
I have been trying to get a little !define command working pulling words from chat (discord) and returning the results from an API.
i can code the api search (Curl in php) to either accept 1 string with all words concatenated
i.e.
$term = $_GET[“t”];
define.php?t=[input from nightbot]
or i can code the api search to accept 2 strings and concatenate them myself
i.e.
$term = $_GET[“t”];
$term .= $_GET[“t2”];
define.php?t=[input from nightbot]&t2=[2nd input from nightbot]
the issue i have is that i want the command to work if there is only 1 argument given in discord.
for example i can get “!define arg1 arg2” to work but !define arg1" does not work
what value is passed by “$(2)” if nothing is entered? something must be being passed when it is empty as it breaks the command.
i have tried
$(urlfetch http://websiteurl/define.php?t=$(eval ‘$(1)’ + ‘$(2)’))
to concatenate on nightbots end which works if $(1) and $(2) are given but not if only $(1) is defined
and
$(urlfetch http://websiteurl/define.php?t=$(1)&t2=$(2))
to concatenate on my end, which again works if $(1) and $(2) are given but not if only $(1) is defined
basically i want to find out why it doesnt work if $(2) is undefined and if there is a way to get around this
kind regards
mark