Hello, I'm trying to work on a project that involves doing some type of user lookup in a database.
My current code looks like this:
public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => builder .setName("find") .setDescription("Find a user on the server list.") .addStringOption((option) => option .setName("user") .setDescription("User to find.") .setRequired(true), ) .setDMPermission(false) .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers), ); }
public override registerApplicationCommands(registry: Command.Registry) { registry.registerChatInputCommand((builder) => builder .setName("find") .setDescription("Find a user on the server list.") .addStringOption((option) => option .setName("user") .setDescription("User to find.") .setRequired(true), ) .setDMPermission(false) .setDefaultMemberPermissions(PermissionFlagsBits.KickMembers), ); }
Ideally, I want the user to be able to provide either a user @mention, or a user ID, or even a username. What would be the best way to approach this?
Solution
instead of adding a string option, add a user option. You can see this in action with many of @Spinel 's commands for the