@ -3,7 +3,7 @@ use serde_json::Map;
use crate ::serenity ;
use crate ::serenity ;
use crate ::Error ;
use crate ::Error ;
use crate ::{ Context , PrefixContext } ;
use crate ::Context ;
use poise ::command ;
use poise ::command ;
use slug ::slugify ;
use slug ::slugify ;
@ -418,10 +418,13 @@ pub async fn imagedelete(ctx: Context<'_>, number: i32) -> Result<(), Error> {
// TODO: make also slash command
// TODO: make also slash command
#[ command(
#[ command(
prefix_command ,
prefix_command ,
slash_command ,
ephemeral ,
description_localized ( "en-US" , "Make a suggestion for future challenge prompts!" )
description_localized ( "en-US" , "Make a suggestion for future challenge prompts!" )
) ]
) ]
pub async fn suggest (
pub async fn suggest (
ctx : PrefixContext < ' _ > ,
ctx : Context < ' _ > ,
#[ rest ]
#[ description = " Suggestion text. Please include passage and source. " ] suggestion : String ,
#[ description = " Suggestion text. Please include passage and source. " ] suggestion : String ,
) -> Result < ( ) , Error > {
) -> Result < ( ) , Error > {
let guild_data = get_guild_data ( ) ;
let guild_data = get_guild_data ( ) ;
@ -434,16 +437,16 @@ pub async fn suggest(
) ;
) ;
// User::accent_colour is only available via the REST API
// User::accent_colour is only available via the REST API
// If we just do msg.author.accent_colour here, we will get None
// If we just do msg.author.accent_colour here, we will get None
let author = & ctx . msg. author;
let author = & ctx . author( ) ;
let accent_color = ctx
let accent_color = ctx
. discord
. discord ( )
. http
. http
. get_user ( * author . id . as_u64 ( ) )
. get_user ( * author . id . as_u64 ( ) )
. await
. await
. unwrap ( )
. unwrap ( )
. accent_colour ;
. accent_colour ;
channel
channel
. send_message ( & ctx . discord .http , | m | {
. send_message ( & ctx . discord () .http , | m | {
m . allowed_mentions ( | am | {
m . allowed_mentions ( | am | {
am . empty_parse ( ) ;
am . empty_parse ( ) ;
am
am
@ -451,11 +454,14 @@ pub async fn suggest(
m . embed ( | e | {
m . embed ( | e | {
let username = format! ( "{}#{}" , author . name , author . discriminator ) ;
let username = format! ( "{}#{}" , author . name , author . discriminator ) ;
e . title ( "New suggestion" ) ;
e . title ( "New suggestion" ) ;
e . description ( format! (
e . description ( if let Context ::Prefix ( ctx ) = ctx {
"{}\n\n[See original message]({})" ,
format! (
suggestion ,
"{suggestion}\n\n[See original message]({})" ,
ctx . msg . link ( ) ,
ctx . msg . link ( ) ,
) ) ;
)
} else {
suggestion
} ) ;
let mut embed_author = serenity ::builder ::CreateEmbedAuthor ::default ( ) ;
let mut embed_author = serenity ::builder ::CreateEmbedAuthor ::default ( ) ;
embed_author
embed_author
. icon_url ( get_avatar ( & author ) )
. icon_url ( get_avatar ( & author ) )
@ -471,6 +477,6 @@ pub async fn suggest(
} )
} )
. await
. await
. unwrap ( ) ;
. unwrap ( ) ;
ctx . msg. reply ( & ctx . discord . http , "Suggestion sent! Thank you for making a suggestion. If it is chosen to be used in a future challenge, you will be mentioned in the challenge description!" ) . await ? ;
ctx . say( "Suggestion sent! Thank you for making a suggestion. If it is chosen to be used in a future challenge, you will be mentioned in the challenge description!" ) . await ? ;
Ok ( ( ) )
Ok ( ( ) )
}
}