@@ -587,7 +587,12 @@ class DPP_EXPORT cluster {
587587 * @return bool Returns `true` if the command was registered successfully, or `false` if
588588 * the command with the same name already exists
589589 */
590- bool register_command (const std::string& name, const slashcommand_handler_t handler);
590+ template <typename F>
591+ std::enable_if_t <utility::callable_returns_v<F, void , const slashcommand_t &>, bool > register_command (const std::string& name, F&& handler) {
592+ std::unique_lock lk (named_commands_mutex);
593+ auto [_, inserted] = named_commands.try_emplace (name, std::forward<F>(handler));
594+ return inserted;
595+ }
591596
592597 /* *
593598 * @brief Get the number of currently active HTTP(S) requests active in the cluster.
@@ -608,12 +613,12 @@ class DPP_EXPORT cluster {
608613 * the command with the same name already exists.
609614 */
610615 template <typename F>
611- std:: enable_if_t <std::is_same_v<std:: invoke_result_t < F, const slashcommand_handler_t &>, dpp::task<void >>, bool >
612- register_command (const std::string& name, F&& handler){
616+ requires (utility::callable_returns< F, dpp::task<void >, const slashcommand_t &>)
617+ bool register_command(const std::string& name, F&& handler) {
613618 std::unique_lock lk (named_commands_mutex);
614- auto [_, inserted] = named_commands.try_emplace (name, std::forward<F>(handler));
619+ auto [_, inserted] = named_commands.try_emplace (name, std::in_place_type< co_slashcommand_handler_t >, std:: forward<F>(handler));
615620 return inserted;
616- };
621+ }
617622#endif
618623
619624 /* *
0 commit comments