Fixed vscode settings issue with rust analyzer. Testing command errors

main
Joey Pollack 2 years ago
parent 7936b24d28
commit b27134a759

20
.gitignore vendored

@ -1,19 +1 @@
# ---> Rust /target
# Generated by Cargo
# will have compiled files and executables
debug/
target/
# Remove Cargo.lock from gitignore if creating an executable, leave it for libraries
# More information here https://doc.rust-lang.org/cargo/guide/cargo-toml-vs-cargo-lock.html
Cargo.lock
# These are backup files generated by rustfmt
**/*.rs.bk
# MSVC Windows builds of rustc generate these, which store debugging information
*.pdb
# SECRETS
secrets/

@ -1,6 +1,3 @@
{ {
"rust-analyzer.linkedProjects": [
".\\Cargo.toml",
".\\Cargo.toml"
]
} }

1420
Cargo.lock generated

File diff suppressed because it is too large Load Diff

@ -1,6 +1,6 @@
MIT License MIT License
Copyright (c) <year> <copyright holders> Copyright (c) 2023 Joseph R Pollack
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:

@ -0,0 +1,22 @@
use super::utils;
use serenity::model::channel::Message;
use serenity::prelude::*;
pub struct Commands;
impl Commands
{
pub async fn randomizer(ctx: Context, msg: Message) -> Result<(), String>
{
let item = utils::get_random_item();
//if let Err(why) = msg.channel_id.say(&ctx.http, format!("You found {}!", item)).await
// {
//return Err(format!("Error sending message: {:?}", why));
return Err(format!("Error sending message: {:?}", "TESTING ERROR"));
// }
Ok(())
}
}

@ -1,8 +1,9 @@
mod utils;
mod commands; mod commands;
mod data_loader; mod data_loader;
mod utils;
use commands::Commands;
use serenity::async_trait; use serenity::async_trait;
use serenity::model::channel::Message; use serenity::model::channel::Message;
@ -35,10 +36,9 @@ impl EventHandler for Handler
if msg.content == ".randomizer" if msg.content == ".randomizer"
{ {
let item = utils::get_random_item(); if let Err(why) = Commands::randomizer(ctx, msg.clone()).await
if let Err(why) = msg.channel_id.say(&ctx.http, format!("You found {}!", item)).await
{ {
println!("Error sending message: {:?}", why); utils::print_command_err(".randomizer", msg.clone(), &why);
} }
} }
} }

@ -1,4 +1,6 @@
use rand::prelude::*; use rand::prelude::*;
use serenity::model::channel::Message;
pub fn get_random_item() -> String pub fn get_random_item() -> String
{ {
@ -35,4 +37,9 @@ pub fn get_random_item() -> String
} }
pub fn print_command_err(command: &str, msg: Message, why: &str)
{
println!("Failed to process command \"{}\" (Sent by: {}, in server: {:?}, in channel: {}): {}", command, msg.author.name, msg.guild_id, msg.channel_id, why);
}