Add link to original message in pinned embed
This commit is contained in:
parent
1430bbf2a9
commit
326324ca1c
|
@ -33,10 +33,28 @@ fn pinned(ctx: &mut Context, message: &Message, mut args: Args) -> CommandResult
|
|||
return Err(CommandError(s!("Index out of bounds!")));
|
||||
}
|
||||
|
||||
let channel = match pinned[idx].channel(&ctx) {
|
||||
Some(g) => g,
|
||||
None => return Err(CommandError(s!("Could not get Channel"))),
|
||||
};
|
||||
|
||||
let guild_arc = match channel.guild() {
|
||||
Some(a) => a,
|
||||
None => return Err(CommandError(s!("Could not find Guild Arc"))),
|
||||
};
|
||||
let guild = guild_arc.read();
|
||||
let guild_id = guild.guild_id;
|
||||
|
||||
let msg_link = format!(
|
||||
"https://discordapp.com/channels/{}/{}/{}",
|
||||
guild_id, &pinned[idx].channel_id, &pinned[idx].id
|
||||
);
|
||||
|
||||
let _ = message.channel_id.send_message(&ctx.http, |m| {
|
||||
m.embed(|e| {
|
||||
e.title(format!("Pinned message #{}", idx + 1))
|
||||
.description(&pinned[idx].content)
|
||||
.field("🔗 link", format!("[original message]({})", msg_link), true)
|
||||
.timestamp(&pinned[idx].timestamp);
|
||||
e.author(|a| {
|
||||
a.name(&pinned[idx].author.name)
|
||||
|
|
14
src/main.rs
14
src/main.rs
|
@ -472,20 +472,18 @@ fn owo(ctx: &mut Context, message: &Message, args: Args) -> CommandResult {
|
|||
use owoify::OwOifiable;
|
||||
|
||||
let lastmsg = match message
|
||||
.channel_id
|
||||
.messages(&ctx.http, |get| get.before(message.id)
|
||||
.limit(1)) {
|
||||
.channel_id
|
||||
.messages(&ctx.http, |get| get.before(message.id).limit(1))
|
||||
{
|
||||
Ok(v) => v,
|
||||
Err(_) => return Err(CommandError(s!("Could not get last message!")))
|
||||
Err(_) => return Err(CommandError(s!("Could not get last message!"))),
|
||||
};
|
||||
|
||||
let ref lastmsg = lastmsg[0].content;
|
||||
|
||||
let input: String = match args.is_empty() {
|
||||
true => {
|
||||
s!(lastmsg)
|
||||
},
|
||||
false => args.rest().trim().to_string()
|
||||
true => s!(lastmsg),
|
||||
false => args.rest().trim().to_string(),
|
||||
};
|
||||
let _ = message.channel_id.say(&ctx.http, input.owoify());
|
||||
|
||||
|
|
Loading…
Reference in New Issue