serenity-rs / serenity

A Rust library for the Discord API.
https://discord.gg/serenity-rs
ISC License
4.78k stars 583 forks source link

Unresolved import for serenity::utils::CreateQuickModal v0.12.2 #2978

Closed Matheuswells closed 1 month ago

Matheuswells commented 1 month ago
use serenity::builder::*;
use serenity::model::prelude::*;
use serenity::prelude::*;

pub async fn run(ctx: &Context, interaction: &CommandInteraction) -> Result<(), serenity::Error> {
    let modal = CreateQuickModal::new("About you")
        .timeout(std::time::Duration::from_secs(600))
        .short_field("First name")
        .short_field("Last name")
        .paragraph_field("Hobbies and interests");
    let response = interaction.quick_modal(ctx, modal).await?.unwrap();

    let inputs = response.inputs;
    let (first_name, last_name, hobbies) = (&inputs[0], &inputs[1], &inputs[2]);

    response
        .interaction
        .create_response(
            ctx,
            CreateInteractionResponse::Message(CreateInteractionResponseMessage::new().content(
                format!("**Name**: {first_name} {last_name}\n\nHobbies and interests: {hobbies}"),
            )),
        )
        .await?;
    Ok(())
}

pub fn register() -> CreateCommand {
    CreateCommand::new("modal").description("Asks some details about you")
}

image

image

jamesbt365 commented 1 month ago

What features do you have enabled? Show your full cargo.toml.

Matheuswells commented 1 month ago

Moved to https://github.com/serenity-rs/serenity/issues/2979

jamesbt365 commented 1 month ago

You disabled the default features alongside the utils feature, which is required here.

jamesbt365 commented 1 month ago

For more information in the future, please check out our docs for the crate.

Matheuswells commented 1 month ago

here is my cargo.toml

[package]
name = "*******"
version = "0.1.0"
edition = "2021"
authors = ["******<*****@*****.***>"]

[dependencies]
tokio = { version = "1.40.0", features = ["rt", "rt-multi-thread", "macros"] }
serenity = { default-features = false, features = [
    "client",
    "gateway",
    "model",
    "rustls_backend",
    "framework",
    "standard_framework",
], version = "0.12.2" }

dotenvy = "0.15"

checking the docs it works after enabling utils and collector features

tks for the help @jamesbt365 my bad about the multiple issues