Cargo fmt
And fix pagination for ephemeral commands
This commit is contained in:
parent
8d8662be75
commit
fff7611e9b
|
@ -21,22 +21,20 @@ async fn autocomplete_role<'a>(
|
|||
.get_table("roles")
|
||||
.unwrap()
|
||||
.get(&ctx.guild_id().expect("Not in a guild").to_string())
|
||||
{
|
||||
None => {vec![]}
|
||||
Some(val) => {
|
||||
match val.clone()
|
||||
.into_table()
|
||||
{
|
||||
Err(_) => {vec![]}
|
||||
Ok(val) => {
|
||||
val.into_keys()
|
||||
.filter(|str| {str.contains(partial)})
|
||||
.collect()
|
||||
}
|
||||
}
|
||||
|
||||
{
|
||||
None => {
|
||||
vec![]
|
||||
}
|
||||
Some(val) => match val.clone().into_table() {
|
||||
Err(_) => {
|
||||
vec![]
|
||||
}
|
||||
};
|
||||
Ok(val) => val
|
||||
.into_keys()
|
||||
.filter(|str| str.contains(partial))
|
||||
.collect(),
|
||||
},
|
||||
};
|
||||
|
||||
roles.sort_unstable();
|
||||
|
||||
|
@ -84,8 +82,8 @@ pub async fn roles(
|
|||
mem.remove_role(ctx, role_ding).await?;
|
||||
ctx.say(format!("Role {} Added", role)).await?
|
||||
} else {
|
||||
mem.add_role(ctx, role_ding).await?;
|
||||
ctx.say(format!("Role {} Added", role)).await?
|
||||
mem.add_role(ctx, role_ding).await?;
|
||||
ctx.say(format!("Role {} Added", role)).await?
|
||||
}
|
||||
}
|
||||
};
|
||||
|
|
|
@ -44,6 +44,7 @@ pub fn paginator(input: Vec<String>, chunk_size: usize, join_string: String) ->
|
|||
return result;
|
||||
}
|
||||
|
||||
|
||||
pub async fn paginate_string(ctx: Context<'_>, pages: Vec<String>) -> Result<(), Error> {
|
||||
let uuid_command = ctx.id().to_string();
|
||||
let page_count = pages.len();
|
||||
|
@ -60,7 +61,7 @@ pub async fn paginate_string(ctx: Context<'_>, pages: Vec<String>) -> Result<(),
|
|||
_ => {}
|
||||
};
|
||||
|
||||
ctx.send(|m| {
|
||||
let reply_handle = ctx.send(|m| {
|
||||
m.content(format!(
|
||||
"{}\n\nPage: {}/{}",
|
||||
pages.get(0).unwrap(),
|
||||
|
@ -115,8 +116,7 @@ pub async fn paginate_string(ctx: Context<'_>, pages: Vec<String>) -> Result<(),
|
|||
page = 0;
|
||||
}
|
||||
|
||||
let mut msg = mci.message.clone();
|
||||
msg.edit(ctx, |m| {
|
||||
reply_handle.edit(ctx, |m| {
|
||||
m.content(format!(
|
||||
"{}\n\nPage: {}/{}",
|
||||
pages.get(page).unwrap(),
|
||||
|
@ -157,7 +157,7 @@ pub async fn paginate_string_embed(
|
|||
_ => {}
|
||||
};
|
||||
|
||||
ctx.send(|m| {
|
||||
let reply_handle = ctx.send(|m| {
|
||||
// m.content(format!(
|
||||
// "{}\n\nPage: {}/{}",
|
||||
// pages.get(0).unwrap(),
|
||||
|
@ -216,8 +216,7 @@ pub async fn paginate_string_embed(
|
|||
page = 0;
|
||||
}
|
||||
|
||||
let mut msg = mci.message.clone();
|
||||
msg.edit(ctx, |m| {
|
||||
reply_handle.edit(ctx, |m| {
|
||||
m.embed(|e| {
|
||||
e.title(format!("{} Page {}/{}", title, page + 1, page_count))
|
||||
.description(pages.get(page).unwrap())
|
||||
|
|
Loading…
Reference in a new issue