merge: Merged message context and rocket api

This commit is contained in:
Alexey 2025-12-24 14:35:15 +03:00
commit d584340f01
2 changed files with 10 additions and 6 deletions

View file

@ -310,7 +310,7 @@ pub async fn update(
Ok(()) Ok(())
} }
pub async fn publish_inner(ctx: Context<'_>, quest: &mut Quest) -> Result<(), Error> { pub async fn publish_inner(ctx: Context<'_>, quest: &mut Quest) -> Result<Message, Error> {
quest.public = true; quest.public = true;
let quests_path = ctx.data().config.full_quests_path(); let quests_path = ctx.data().config.full_quests_path();
@ -327,8 +327,10 @@ pub async fn publish_inner(ctx: Context<'_>, quest: &mut Quest) -> Result<(), Er
guard.quests_channel guard.quests_channel
}; };
channel.send_message(ctx, builder).await?; match channel.send_message(ctx, builder).await {
Ok(()) Ok(m) => Ok(m),
Err(error) => Err(Error::SerenityError(error)),
}
} }
/// Mark quest as public and send its message in quests channel /// Mark quest as public and send its message in quests channel
@ -357,10 +359,12 @@ pub async fn publish(
return Err(Error::QuestIsPublic(id)); return Err(Error::QuestIsPublic(id));
} }
publish_inner(ctx, quest).await?; let message = publish_inner(ctx, quest).await?;
let strings = &ctx.data().strings; let strings = &ctx.data().strings;
let formatter = strings.formatter().quest(&quest); let formatter = strings.formatter()
.quest(&quest)
.message(&message);
let reply_string = formatter.fmt(&strings.quest.publish); let reply_string = formatter.fmt(&strings.quest.publish);
ctx.reply(reply_string).await?; ctx.reply(reply_string).await?;

View file

@ -328,7 +328,7 @@ impl Default for QuestStrings {
list_item: "{n}{q.id}: {q.name}{n} Description: {q.description}".to_string(), list_item: "{n}{q.id}: {q.name}{n} Description: {q.description}".to_string(),
create: "Created quest {q.id}".to_string(), create: "Created quest {q.id}".to_string(),
update: "Updated quest {q.id}".to_string(), update: "Updated quest {q.id}".to_string(),
publish: "Published quest {q.id}: {text}".to_string(), publish: "Published quest {q.id}: {m.link}".to_string(),
delete: "Deleted quest {q.id}".to_string(), delete: "Deleted quest {q.id}".to_string(),
message_format: "### `{q.id}` {q.name} (+{q.reward}){n}\ message_format: "### `{q.id}` {q.name} (+{q.reward}){n}\
Difficulty: *{q.difficulty}*{n}\ Difficulty: *{q.difficulty}*{n}\