@@ -3090,6 +3090,209 @@ typedef std::unordered_map<snowflake, message> message_map;
30903090 */
30913091typedef std::unordered_map<snowflake, message_pin> message_pin_map;
30923092
3093+ /* *
3094+ * @brief Possible values for the "has" filter in message search
3095+ */
3096+ enum message_search_has : uint8_t {
3097+ has_image,
3098+ has_sound,
3099+ has_video,
3100+ has_file,
3101+ has_sticker,
3102+ has_embed,
3103+ has_link,
3104+ has_poll,
3105+ has_snapshot,
3106+ };
3107+
3108+ /* *
3109+ * @brief Sort mode for message search results
3110+ */
3111+ enum message_search_sort : uint8_t {
3112+ sort_timestamp,
3113+ sort_relevance,
3114+ };
3115+
3116+ /* *
3117+ * @brief Sort order for message search results
3118+ */
3119+ enum message_search_order : uint8_t {
3120+ sort_desc,
3121+ sort_asc,
3122+ };
3123+
3124+ /* *
3125+ * @brief Parameters for searching messages within a guild
3126+ * @see https://discord.com/developers/docs/resources/message#search-guild-messages
3127+ */
3128+ struct DPP_EXPORT message_search_params {
3129+ /* *
3130+ * @brief Filter messages by content (max 1024 characters)
3131+ */
3132+ std::string content;
3133+
3134+ /* *
3135+ * @brief Filter by author IDs (max 100)
3136+ */
3137+ std::vector<snowflake> author_id;
3138+
3139+ /* *
3140+ * @brief Filter messages that mention these users (max 100)
3141+ */
3142+ std::vector<snowflake> mentions;
3143+
3144+ /* *
3145+ * @brief Filter by channel IDs (max 500)
3146+ */
3147+ std::vector<snowflake> channel_id;
3148+
3149+ /* *
3150+ * @brief Filter messages that mention these roles (max 100)
3151+ */
3152+ std::vector<snowflake> mentions_role_id;
3153+
3154+ /* *
3155+ * @brief Filter messages that reply to these users (max 100)
3156+ */
3157+ std::vector<snowflake> replied_to_user_id;
3158+
3159+ /* *
3160+ * @brief Filter messages that reply to these messages (max 100)
3161+ */
3162+ std::vector<snowflake> replied_to_message_id;
3163+
3164+ /* *
3165+ * @brief Filter by author type (user, bot, webhook; prefix with - to negate)
3166+ */
3167+ std::vector<std::string> author_type;
3168+
3169+ /* *
3170+ * @brief Filter by presence of element types
3171+ */
3172+ std::vector<message_search_has> has;
3173+
3174+ /* *
3175+ * @brief Filter messages by embed type
3176+ */
3177+ std::vector<std::string> embed_type;
3178+
3179+ /* *
3180+ * @brief Filter messages by embed provider (case-sensitive, max 100)
3181+ */
3182+ std::vector<std::string> embed_provider;
3183+
3184+ /* *
3185+ * @brief Filter messages by link hostname (max 100)
3186+ */
3187+ std::vector<std::string> link_hostname;
3188+
3189+ /* *
3190+ * @brief Filter messages by attachment filename (max 100)
3191+ */
3192+ std::vector<std::string> attachment_filename;
3193+
3194+ /* *
3195+ * @brief Filter messages by attachment extension (max 100)
3196+ */
3197+ std::vector<std::string> attachment_extension;
3198+
3199+ /* *
3200+ * @brief Get messages before this message ID
3201+ */
3202+ snowflake max_id;
3203+
3204+ /* *
3205+ * @brief Get messages after this message ID
3206+ */
3207+ snowflake min_id;
3208+
3209+ /* *
3210+ * @brief Filter messages by whether they are pinned
3211+ */
3212+ std::optional<bool > pinned;
3213+
3214+ /* *
3215+ * @brief Filter by @everyone mention presence
3216+ */
3217+ std::optional<bool > mention_everyone;
3218+
3219+ /* *
3220+ * @brief Whether to include results from age-restricted channels (default false)
3221+ */
3222+ std::optional<bool > include_nsfw;
3223+
3224+ /* *
3225+ * @brief Max number of messages to return (1-25, default 25)
3226+ */
3227+ std::optional<uint32_t > limit;
3228+
3229+ /* *
3230+ * @brief Pagination offset (max 9975)
3231+ */
3232+ std::optional<uint32_t > offset;
3233+
3234+ /* *
3235+ * @brief Max number of words to skip between matching tokens (max 100, default 2)
3236+ */
3237+ std::optional<uint32_t > slop;
3238+
3239+ /* *
3240+ * @brief Sorting algorithm to use (default: sort_timestamp)
3241+ */
3242+ std::optional<message_search_sort> sort_by;
3243+
3244+ /* *
3245+ * @brief Direction to sort (default: sort_desc)
3246+ */
3247+ std::optional<message_search_order> sort_order;
3248+
3249+ /* *
3250+ * @brief Build the query string for the REST request
3251+ * @return URL query string starting with '?'
3252+ */
3253+ std::string build_url_params () const ;
3254+ };
3255+
3256+ /* *
3257+ * @brief Represents the result of a guild message search
3258+ * @see https://discord.com/developers/docs/resources/message#search-guild-messages
3259+ */
3260+ struct DPP_EXPORT message_search_result : public json_interface<message_search_result> {
3261+ protected:
3262+ friend struct json_interface <message_search_result>;
3263+
3264+ /* *
3265+ * @brief Fill from JSON
3266+ * @param j JSON data
3267+ * @return Reference to self
3268+ */
3269+ message_search_result& fill_from_json_impl (nlohmann::json* j);
3270+
3271+ public:
3272+ message_search_result () = default ;
3273+
3274+ /* *
3275+ * @brief Total number of results matching the query
3276+ */
3277+ uint32_t total_results{0 };
3278+
3279+ /* *
3280+ * @brief Whether a deep historical index is being performed
3281+ */
3282+ bool doing_deep_historical_index{false };
3283+
3284+ /* *
3285+ * @brief Number of documents indexed so far (only present during deep indexing)
3286+ */
3287+ std::optional<uint32_t > documents_indexed;
3288+
3289+ /* *
3290+ * @brief Matched messages grouped by context.
3291+ * Each inner vector contains the matched message followed by context messages.
3292+ */
3293+ std::vector<std::vector<message>> messages;
3294+ };
3295+
30933296/* *
30943297 * @brief A group of stickers
30953298 */
0 commit comments