refactor: clean up main
This commit is contained in:
parent
4a821a2ca3
commit
5ea60282f3
1 changed files with 3 additions and 31 deletions
34
src/main.rs
34
src/main.rs
|
@ -44,15 +44,10 @@ async fn main() {
|
||||||
let config: Config =
|
let config: Config =
|
||||||
toml::de::from_str(&config_file_contents).expect("failed to deserialize config file");
|
toml::de::from_str(&config_file_contents).expect("failed to deserialize config file");
|
||||||
|
|
||||||
println!("{config:?}");
|
|
||||||
|
|
||||||
let options = poise::FrameworkOptions {
|
let options = poise::FrameworkOptions {
|
||||||
commands: vec![commands::ping::ping(), commands::sandwich::sandwich_list()],
|
commands: vec![commands::ping::ping(), commands::sandwich::sandwich_list()],
|
||||||
prefix_options: poise::PrefixFrameworkOptions {
|
prefix_options: poise::PrefixFrameworkOptions {
|
||||||
prefix: Some("!".into()),
|
prefix: Some("!".into()),
|
||||||
edit_tracker: Some(Arc::new(poise::EditTracker::for_timespan(
|
|
||||||
Duration::from_secs(3600),
|
|
||||||
))),
|
|
||||||
additional_prefixes: vec![
|
additional_prefixes: vec![
|
||||||
poise::Prefix::Literal("sandwichmeister,"),
|
poise::Prefix::Literal("sandwichmeister,"),
|
||||||
poise::Prefix::Literal("sandwichmeister"),
|
poise::Prefix::Literal("sandwichmeister"),
|
||||||
|
@ -61,32 +56,6 @@ async fn main() {
|
||||||
],
|
],
|
||||||
..Default::default()
|
..Default::default()
|
||||||
},
|
},
|
||||||
// The global error handler for all error cases that may occur
|
|
||||||
on_error: |error| Box::pin(on_error(error)),
|
|
||||||
// This code is run before every command
|
|
||||||
pre_command: |ctx| {
|
|
||||||
Box::pin(async move {
|
|
||||||
println!("Executing command {}...", ctx.command().qualified_name);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// This code is run after a command if it was successful (returned Ok)
|
|
||||||
post_command: |ctx| {
|
|
||||||
Box::pin(async move {
|
|
||||||
println!("Executed command {}!", ctx.command().qualified_name);
|
|
||||||
})
|
|
||||||
},
|
|
||||||
// Every command invocation must pass this check to continue execution
|
|
||||||
// command_check: Some(|ctx| {
|
|
||||||
// Box::pin(async move {
|
|
||||||
// if ctx.author().id == 123456789 {
|
|
||||||
// return Ok(false);
|
|
||||||
// }
|
|
||||||
// Ok(true)
|
|
||||||
// })
|
|
||||||
// }),
|
|
||||||
// Enforce command checks even for owners (enforced by default)
|
|
||||||
// Set to true to bypass checks, which is useful for testing
|
|
||||||
skip_checks_for_owners: false,
|
|
||||||
event_handler: |_ctx, event, _framework, _data| {
|
event_handler: |_ctx, event, _framework, _data| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
println!(
|
println!(
|
||||||
|
@ -103,8 +72,11 @@ async fn main() {
|
||||||
.setup(move |ctx, _ready, framework| {
|
.setup(move |ctx, _ready, framework| {
|
||||||
Box::pin(async move {
|
Box::pin(async move {
|
||||||
println!("Logged in as {}", _ready.user.name);
|
println!("Logged in as {}", _ready.user.name);
|
||||||
|
|
||||||
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
poise::builtins::register_globally(ctx, &framework.options().commands).await?;
|
||||||
|
|
||||||
let directus = DirectusClient::new(config.directus);
|
let directus = DirectusClient::new(config.directus);
|
||||||
|
|
||||||
let sandwiches = directus
|
let sandwiches = directus
|
||||||
.get_sandwiches()
|
.get_sandwiches()
|
||||||
.await
|
.await
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue