diff --git a/examples/e03_struct_utilities/src/main.rs b/examples/e03_struct_utilities/src/main.rs index 29a854ba0a9..825ac1032ef 100644 --- a/examples/e03_struct_utilities/src/main.rs +++ b/examples/e03_struct_utilities/src/main.rs @@ -19,10 +19,14 @@ impl EventHandler for Handler { // In this case, you can direct message a User directly by simply // calling a method on its instance, with the content of the // message. - let dm = msg.author.dm(&context, |m| m.content("Hello!")).await; - - if let Err(why) = dm { - println!("Error when direct messaging user: {:?}", why); + match msg.author.dm(&context).await { + Ok(create_message) => { + let msg = create_message.content("Hello!").execute(&context).await; + if let Err(why) = msg { + println!("Error when direct messaging user: {:?}", why); + } + }, + Err(why) => println!("Error when direct messaging user: {:?}", why), } } } diff --git a/examples/e14_slash_commands/src/main.rs b/examples/e14_slash_commands/src/main.rs index a58670862f9..330bd243807 100644 --- a/examples/e14_slash_commands/src/main.rs +++ b/examples/e14_slash_commands/src/main.rs @@ -1,6 +1,7 @@ use std::env; use serenity::async_trait; +use serenity::builder::*; use serenity::model::application::command::{Command, CommandOptionType}; use serenity::model::application::interaction::application_command::CommandDataOptionValue; use serenity::model::application::interaction::{Interaction, InteractionResponseType}; @@ -56,12 +57,12 @@ impl EventHandler for Handler { _ => "not implemented :(".to_string(), }; + let data = CreateInteractionResponseData::default().content(content); if let Err(why) = command - .create_interaction_response(&ctx.http, |response| { - response - .kind(InteractionResponseType::ChannelMessageWithSource) - .interaction_response_data(|message| message.content(content)) - }) + .create_interaction_response() + .kind(InteractionResponseType::ChannelMessageWithSource) + .interaction_response_data(data) + .execute(&ctx.http) .await { println!("Cannot respond to slash command: {}", why); diff --git a/src/model/channel/channel_id.rs b/src/model/channel/channel_id.rs index 6377cdcda9a..0f81f615cd7 100644 --- a/src/model/channel/channel_id.rs +++ b/src/model/channel/channel_id.rs @@ -715,7 +715,11 @@ impl ChannelId { /// Refer to the documentation for [`CreateMessage`] for more information regarding message /// restrictions and requirements. pub fn send_message<'a>(self) -> CreateMessage<'a> { - CreateMessage::new(self, None) + CreateMessage::new( + self, + #[cfg(feature = "cache")] + None, + ) } /// Starts typing in the channel for an indefinite period of time. diff --git a/src/model/channel/guild_channel.rs b/src/model/channel/guild_channel.rs index f265ca4daa9..3cc04d59e2c 100644 --- a/src/model/channel/guild_channel.rs +++ b/src/model/channel/guild_channel.rs @@ -911,7 +911,11 @@ impl GuildChannel { /// Refer to the documentation for [`CreateMessage`] for more information regarding message /// restrictions and requirements. pub fn send_message<'a>(&self) -> CreateMessage<'a> { - CreateMessage::new(self.id, Some(self.guild_id)) + CreateMessage::new( + self.id, + #[cfg(feature = "cache")] + Some(self.guild_id), + ) } /// Starts typing in the channel for an indefinite period of time.