Fix suggestions

late-submissions
Elnu 2 years ago
parent 4416a8f71c
commit 61973f617d

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

@ -5,7 +5,7 @@ use std::env;
type Error = Box<dyn std::error::Error + Send + Sync>;
type Context<'a> = poise::Context<'a, Data, Error>;
type PrefixContext<'a> = poise::PrefixContext<'a, Data, Error>;
// type PrefixContext<'a> = poise::PrefixContext<'a, Data, Error>;
// User data, which is stored and accessible in all command invocations
pub struct Data {}

Loading…
Cancel
Save