Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We鈥檒l occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update messaging #3

Merged
merged 1 commit into from Jul 28, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
8 changes: 4 additions & 4 deletions src/commands/clean.rs
Expand Up @@ -22,7 +22,7 @@ pub async fn run(
interaction_reply_ephemeral(
command,
ctx,
"There is no database instance currently associated with this channel",
":warning: There is no database instance currently associated with this channel",
)
.await?;
return Ok(());
Expand All @@ -31,12 +31,12 @@ pub async fn run(
let channel = match command.channel_id.to_channel(&ctx).await.unwrap() {
Channel::Guild(c) => c,
_ => {
interaction_reply_ephemeral(command, ctx, "Command only works in guild channels")
interaction_reply_ephemeral(command, ctx, ":warning: This command only works in guild channels")
.await?;
return Ok(());
}
};
interaction_reply_ephemeral(command, ctx.clone(), "This channel should now be cleaned").await?;
interaction_reply_ephemeral(command, ctx.clone(), ":white_check_mark: This channel should now be cleaned").await?;

clean_channel(channel, &ctx).await;

Expand All @@ -46,6 +46,6 @@ pub async fn run(
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
command
.name("clean")
.description("cleans the current channel!")
.description("Cleans the current channel!")
.default_member_permissions(Permissions::MANAGE_CHANNELS)
}
6 changes: 3 additions & 3 deletions src/commands/clean_all.rs
Expand Up @@ -19,7 +19,7 @@ pub async fn run(
let channel = match ChannelId(id.clone()).to_channel(&ctx).await.unwrap() {
Channel::Guild(c) => c,
_ => {
interaction_reply_ephemeral(command, ctx, "Command only works in guild channels")
interaction_reply_ephemeral(command, ctx, ":warning: This command only works in guild channels")
.await?;
return Ok(());
}
Expand All @@ -28,12 +28,12 @@ pub async fn run(
tokio::spawn(async move { clean_channel(channel, &ctx).await });
}

interaction_reply_ephemeral(command, ctx, "Channels should now be cleaned").await
interaction_reply_ephemeral(command, ctx, ":white_check_mark: All channels should now be cleaned").await
}

pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
command
.name("clean_all")
.description("clean all channels, this should only be used before a bot is shut down!")
.description("Cleans all channels, this should only be used before a bot is shutdown!")
.default_member_permissions(Permissions::MANAGE_CHANNELS)
}
10 changes: 5 additions & 5 deletions src/commands/config_update.rs
Expand Up @@ -25,7 +25,7 @@ pub async fn run(
Ok(response) => match response {
Some(c) => {c}

None => return interaction_reply(command, ctx.clone(), format!("This server is not yet configured, use /configure to add initial configuration")).await,
None => return interaction_reply(command, ctx.clone(), format!(":warning: This server is not yet configured, use `/configure` to add initial configuration")).await,
},
Err(e) => return interaction_reply(command, ctx.clone(), format!("Database error: {}", e)).await,
};
Expand All @@ -47,12 +47,12 @@ pub async fn run(
let msg = match updated {
Ok(response) => match response {
Some(c) => {
format!("This server is now configured with: {:?}", c)
format!(":white_check_mark: This server is now configured with: {:?}", c)
}

None => "Error adding configuration".to_string(),
None => ":x: Error adding configuration".to_string(),
},
Err(e) => format!("Database error: {}", e),
Err(e) => format!(":x: Database error: {}", e),
};
interaction_reply(command, ctx.clone(), msg).await
}
Expand All @@ -61,7 +61,7 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
config::register_options(
command
.name("config_update")
.description("Update configuration options for SurrealBot")
.description("Update configuration options for SurrealBot in this server")
.default_member_permissions(Permissions::MANAGE_CHANNELS),
false,
)
Expand Down
10 changes: 5 additions & 5 deletions src/commands/configure.rs
Expand Up @@ -24,7 +24,7 @@ pub async fn run(

match result {
Ok(response) => match response {
Some(c) => return interaction_reply(command, ctx.clone(), format!("This server is already configured with: {:?}\n Try using /configUpdate to change the config", c)).await,
Some(c) => return interaction_reply(command, ctx.clone(), format!(":warning: This server is already configured with: {:?}\n Try using `/config_update` to change the config", c)).await,

None => {}
},
Expand All @@ -40,7 +40,7 @@ pub async fn run(
return interaction_reply_ephemeral(
command,
ctx,
"Error building config, please ensure all fields are present",
":x: Error building config, please ensure all fields are present!",
)
.await;
}
Expand All @@ -57,12 +57,12 @@ pub async fn run(
let msg = match created {
Ok(response) => match response {
Some(c) => {
format!("This server is now configured with: {:?}", c)
format!(":information_source: This server is now configured with: {:?}", c)
}

None => "Error adding configuration".to_string(),
None => ":x: Error adding configuration".to_string(),
},
Err(e) => format!("Database error: {}", e),
Err(e) => format!(":x: Database error: {}", e),
};
interaction_reply(command, ctx.clone(), msg).await
}
Expand Down
12 changes: 6 additions & 6 deletions src/commands/configure_channel.rs
Expand Up @@ -28,7 +28,7 @@ pub async fn run(
command,
ctx,
format!(
"This channel is now configured with pretty printing:{}, json:{}, require_query: {}",
":information_source: **This channel's configuration was updated** \nPretty printing: `{}` \nJSON: `{}` \nRequire query: `{}`",
conn.pretty, conn.json, conn.require_query
),
)
Expand All @@ -37,7 +37,7 @@ pub async fn run(
interaction_reply_ephemeral(
command,
ctx,
"There is no database instance currently associated with this channel",
":warning: There is no database instance currently associated with this channel",
)
.await?;
}
Expand All @@ -48,26 +48,26 @@ pub async fn run(
pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicationCommand {
command
.name("configure_channel")
.description("Update configuration options on a channel for SurrealBot")
.description("Update configuration options on this channel for SurrealBot")
.create_option(|option| {
option
.name("pretty")
.description("whether or not to pretty print responses")
.description("Whether or not to pretty print responses")
.kind(CommandOptionType::Boolean)
.required(false)
})
.create_option(|option| {
option
.name("json")
.description("whether to format output as JSON, the alternative is SurrealQL")
.description("Whether to format output as JSON, the alternative is SurrealQL")
.kind(CommandOptionType::Boolean)
.default_option(false)
.required(false)
})
.create_option(|option| {
option
.name("require_query")
.description("whether the /query command is requred to contact the database")
.description("Whether the /query command is required to send queries to SurrealDB")
.kind(CommandOptionType::Boolean)
.default_option(false)
.required(false)
Expand Down
26 changes: 13 additions & 13 deletions src/commands/connect.rs
Expand Up @@ -27,7 +27,7 @@ pub async fn run(
interaction_reply_ephemeral(
command,
ctx,
"This channel already has an associated database instance",
":information_source: This channel already has an associated database instance",
)
.await?;
return Ok(());
Expand All @@ -41,10 +41,10 @@ pub async fn run(
Ok(response) => {
match response {
Some(c) => {c}
None => return interaction_reply_ephemeral(command, ctx, "No config found for this server, please ask an administrator to configure the bot".to_string()).await
None => return interaction_reply_ephemeral(command, ctx, ":warning: No config found for this server, please ask an administrator to configure the bot!".to_string()).await
}
}
Err(e) => return interaction_reply_ephemeral(command, ctx, format!("Database error: {}", e)).await,
Err(e) => return interaction_reply_ephemeral(command, ctx, format!(":x: Database error: {}", e)).await,
};

let channel = command.channel_id.to_channel(&ctx).await?.guild().unwrap();
Expand All @@ -63,7 +63,7 @@ pub async fn run(

match command.data.options.len().cmp(&1) {
Ordering::Greater => {
interaction_reply_ephemeral(command, ctx, "Please only supply one arguement (you can use the up arrow to edit the previous command)").await?;
interaction_reply_ephemeral(command, ctx, ":information_source: Please only supply one arguement (you can use the up arrow to edit the previous command)").await?;
return Ok(());
}
Ordering::Equal => {
Expand All @@ -78,7 +78,7 @@ pub async fn run(
channel,
command,
"surreal_deal_mini.surql",
"surreal deal(mini)",
"Surreal deal (mini)",
Some("surreal_deal.png"),
)
.await?;
Expand All @@ -90,7 +90,7 @@ pub async fn run(
channel,
command,
"surreal_deal.surql",
"surreal deal",
"Surreal deal",
Some("surreal_deal.png"),
)
.await?;
Expand All @@ -108,21 +108,21 @@ pub async fn run(
}
CommandOptionType::Attachment => load_attachment(op_option, command, ctx, db, channel).await?,
_ => {
interaction_reply_ephemeral(command, ctx, "Unsupported option type")
interaction_reply_ephemeral(command, ctx, ":x: Unsupported option type")
.await?;
return Ok(());
}
}
}
Ordering::Less => interaction_reply(command, ctx, format!("This channel is now connected to a SurrealDB instance, try writing some SurrealQL with the /query command!!!\n(note this channel will expire after {:#?} of inactivity)", config.ttl)).await?,
Ordering::Less => interaction_reply(command, ctx, format!(":information_source: This channel is now connected to a SurrealDB instance, try writing some SurrealQL with the `/query` command! \n_Please note this channel will expire after {:#?} of inactivity._", config.ttl)).await?,
};
return Ok(());
}
None => {
return interaction_reply(
command,
ctx,
"Direct messages are not currently supported".to_string(),
":warning: Direct messages are not currently supported".to_string(),
)
.await;
}
Expand All @@ -137,7 +137,7 @@ pub fn register(command: &mut CreateApplicationCommand) -> &mut CreateApplicatio
.create_option(|option| {
option
.name("file")
.description("a SurrealQL to load into the database instance")
.description("A SurrealQL file to load into the database instance")
.kind(CommandOptionType::Attachment)
.required(false)
})
Expand All @@ -157,7 +157,7 @@ async fn load_premade(
command,
ctx.clone(),
format!(
"Data is currently being loaded, soon you'll be able to query the {} dataset!!!",
":information_source: The dataset is currently being loaded, soon you'll be able to query the {} dataset! \n_Please wait for a confirmation that the dataset is loaded!_",
name
),
)
Expand All @@ -171,7 +171,7 @@ async fn load_premade(
&command,
ctx.clone(),
format!(
"Data is now loaded and you can query the {} dataset with the /query command!!!",
":white_check_mark: The dataset is now loaded and you can query the {} dataset with the `/query` command!",
name
),
)
Expand All @@ -192,7 +192,7 @@ async fn load_premade(
}
}
Err(why) => {
interaction_reply_edit(&command, ctx, format!("Error loading data: {}", why))
interaction_reply_edit(&command, ctx, format!(":x: Error loading data: {}", why))
.await
.unwrap();
}
Expand Down