fixed tedit and tadd
This commit is contained in:
@@ -70,8 +70,8 @@ pub async fn tag(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
|||||||
pub async fn tadd(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
pub async fn tadd(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||||
let query: String = args.raw().collect::<Vec<&str>>().join(" ");
|
let query: String = args.raw().collect::<Vec<&str>>().join(" ");
|
||||||
let queries = query.splitn(2, " ").collect::<Vec<&str>>();
|
let queries = query.splitn(2, " ").collect::<Vec<&str>>();
|
||||||
if queries.len() != 2 {
|
if queries.len() != 2 && msg.attachments.len() == 0 {
|
||||||
msg.reply(ctx, "Please use the proper syntax: `,tadd <name> <value>`")
|
msg.reply(ctx, "Please use the proper syntax: `,tadd <name> <value>` or attach something")
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -95,8 +95,12 @@ pub async fn tadd(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
|||||||
"INSERT INTO tags(name, value, owner) VALUES('{}','{}', '{}')",
|
"INSERT INTO tags(name, value, owner) VALUES('{}','{}', '{}')",
|
||||||
queries[0],
|
queries[0],
|
||||||
format!(
|
format!(
|
||||||
"{}\n{}",
|
"{}{}",
|
||||||
queries[1],
|
if queries.len() == 2 {
|
||||||
|
format!("{}{}", queries[1], '\n')
|
||||||
|
} else {
|
||||||
|
"".to_string()
|
||||||
|
},
|
||||||
msg.attachments
|
msg.attachments
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.url.clone())
|
.map(|x| x.url.clone())
|
||||||
@@ -151,8 +155,8 @@ pub async fn trm(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
|||||||
pub async fn tedit(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
pub async fn tedit(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
||||||
let query: String = args.raw().collect::<Vec<&str>>().join(" ");
|
let query: String = args.raw().collect::<Vec<&str>>().join(" ");
|
||||||
let queries = query.splitn(2, " ").collect::<Vec<&str>>();
|
let queries = query.splitn(2, " ").collect::<Vec<&str>>();
|
||||||
if queries.len() != 2 {
|
if queries.len() != 2 && msg.attachments.len() == 0 {
|
||||||
msg.reply(ctx, "Please use the proper syntax\n`,tedit <name> <value>`")
|
msg.reply(ctx, "Please use the proper syntax or attach something\n`,tedit <name> <value> `")
|
||||||
.await?;
|
.await?;
|
||||||
return Ok(());
|
return Ok(());
|
||||||
}
|
}
|
||||||
@@ -178,8 +182,12 @@ pub async fn tedit(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
|||||||
format!(
|
format!(
|
||||||
"UPDATE tags SET value='{}' WHERE name='{}'",
|
"UPDATE tags SET value='{}' WHERE name='{}'",
|
||||||
format!(
|
format!(
|
||||||
"{}\n{}",
|
"{}{}",
|
||||||
queries[1],
|
if queries.len() == 2 {
|
||||||
|
format!("{}{}", queries[1], '\n')
|
||||||
|
} else {
|
||||||
|
"".to_string()
|
||||||
|
},
|
||||||
msg.attachments
|
msg.attachments
|
||||||
.iter()
|
.iter()
|
||||||
.map(|x| x.url.clone())
|
.map(|x| x.url.clone())
|
||||||
@@ -190,7 +198,8 @@ pub async fn tedit(ctx: &Context, msg: &Message, args: Args) -> CommandResult {
|
|||||||
)
|
)
|
||||||
.as_str(),
|
.as_str(),
|
||||||
&[],
|
&[],
|
||||||
).await?;
|
)
|
||||||
|
.await?;
|
||||||
msg.reply(ctx, "Changed the value if it existed").await?;
|
msg.reply(ctx, "Changed the value if it existed").await?;
|
||||||
Ok(())
|
Ok(())
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user