-
Notifications
You must be signed in to change notification settings - Fork 0
Home
For an overview of all available commands see this section.
This parameter exists on a lot of commands (e.g. /map
). On each of those commands
the bot will give you autocompletion for all map names. Due to Discord limitations it can only show
up to 25 entries at a time though. When you start typing, the bot will fuzzy search the map list
using your input (this is case-insensitive). "Fuzzy search" means you can leave characters out while
typing; lnHRdr
will lead to kz_lionharder
being selected. If you type random garbage that
doesn't match anything, the bot will return an error. The autocompletion seems pretty slow, but I
still think it's a nice feature. I measured it, and the actual selection / search only takes about 1
millisecond. Discord's slow frontend and the fact that all communication happens over network makes
it pretty slow unfortunately.
Internally the bot uses a Target
type for parsing player
parameters. Since all the bot needs is
a SteamID
, it parses the Target
and then tries to somehow get a SteamID
out of it, or a name
if nothing works. After parsing this Target
can be 1 of 4 things:
-
None
-> the user did not specify anything -> take the user's ID -
Mention
-> the user @mention'd someone -> take that user's ID -
SteamID
-> perfect, that's what we need -
Name
-> unlucky because names are inconsistent for API requests, but we take what we get
If we get None
we search for the user's ID in the database. If it exists, we check if there is a
SteamID
. If there is a SteamID
, we take it, otherwise we take the user's name stored in the
database. If there is no database entry to begin with, we take their Discord username.
This is basically the same process as described above, except we use the @mention'd user's ID.
We take that SteamID
and use it for API requests. Since every SteamID
is unique, this is the
most accurate method.
If we only got a name, we will take that for making requests, although it might lead to unexpected
results (imagine a different player with a similar name).
If you are interested in the actual implementation for this, look at the target.rs
file in the
root of the project.