Skip to content

Commit 3b505b2

Browse files
committed
Increase cargo fmt max width
1 parent 36d0e1b commit 3b505b2

14 files changed

+430
-858
lines changed

.rustfmt.toml

+1
Original file line numberDiff line numberDiff line change
@@ -0,0 +1 @@
1+
max_width = 120

build.rs

+4-11
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,7 @@ fn main() -> io::Result<()> {
1212
create_constants(constants_path.as_path())?;
1313
println!(
1414
"cargo:rustc-env=CONSTANTS_PATH={}",
15-
constants_path
16-
.to_str()
17-
.expect("invalid unicode in constants path")
15+
constants_path.to_str().expect("invalid unicode in constants path")
1816
);
1917
Ok(())
2018
}
@@ -31,15 +29,11 @@ fn create_constants<P: AsRef<Path>>(path: P) -> io::Result<()> {
3129
writer.write_fmt(format_args!(
3230
"pub const GIT_COMMIT_HASH: &str = \"{git_commit_hash}\";\n"
3331
))?;
34-
writer.write_fmt(format_args!(
35-
"pub const CLAP_VERSION: &str = \"{clap_version}\";\n"
36-
))?;
32+
writer.write_fmt(format_args!("pub const CLAP_VERSION: &str = \"{clap_version}\";\n"))?;
3733
writer.write_fmt(format_args!(
3834
"pub const DISCORD_BOT_VERSION: &str = \"{discord_bot_version}\";\n"
3935
))?;
40-
writer.write_fmt(format_args!(
41-
"pub const USER_AGENT: &str = \"{user_agent}\";\n"
42-
))?;
36+
writer.write_fmt(format_args!("pub const USER_AGENT: &str = \"{user_agent}\";\n"))?;
4337
writer.flush()
4438
}
4539

@@ -70,8 +64,7 @@ fn git_commit_hash() -> String {
7064
.args(["rev-parse", "HEAD"])
7165
.output()
7266
.expect("failed to get git commit hash");
73-
let untrimmed_git_commit_hash =
74-
String::from_utf8(output.stdout).expect("failed to read git commit hash as UTF-8");
67+
let untrimmed_git_commit_hash = String::from_utf8(output.stdout).expect("failed to read git commit hash as UTF-8");
7568
untrimmed_git_commit_hash.trim().to_string()
7669
}
7770

src/bot/cache.rs

+40-111
Large diffs are not rendered by default.

src/bot/commands/global_commands.rs

+8-30
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,7 @@ thread_local! {
2929
}
3030

3131
/// Shows bot help
32-
#[poise::command(
33-
slash_command,
34-
install_context = "Guild",
35-
interaction_context = "Guild"
36-
)]
32+
#[poise::command(slash_command, install_context = "Guild", interaction_context = "Guild")]
3733
pub(in crate::bot) async fn help(context: Context<'_>) -> Result<(), Error> {
3834
let embed = CreateEmbed::default().title("Jinx Help").description(
3935
"Jinx is a Discord bot that grants roles to users when they register Jinxxy license keys.\n\
@@ -46,11 +42,7 @@ pub(in crate::bot) async fn help(context: Context<'_>) -> Result<(), Error> {
4642
}
4743

4844
/// Shows bot version
49-
#[poise::command(
50-
slash_command,
51-
install_context = "Guild",
52-
interaction_context = "Guild"
53-
)]
45+
#[poise::command(slash_command, install_context = "Guild", interaction_context = "Guild")]
5446
pub(in crate::bot) async fn version(context: Context<'_>) -> Result<(), Error> {
5547
context.defer_ephemeral().await?;
5648
let embed = CreateEmbed::default()
@@ -109,8 +101,7 @@ pub(in crate::bot) async fn init(
109101
// I suspect this is a discord/serenity/poise bug.
110102
// For some <id>, <nonce>, this looks like:
111103
// Http(UnsuccessfulRequest(ErrorResponse { status_code: 404, url: "https://discord.com/api/v10/interactions/<id>/<nonce>/callback", method: POST, error: DiscordJsonError { code: 10062, message: "Unknown interaction", errors: [] } }))
112-
util::set_guild_commands(&context, &context.data().db, guild_id, Some(true), None)
113-
.await?;
104+
util::set_guild_commands(&context, &context.data().db, guild_id, Some(true), None).await?;
114105

115106
success_reply("Success", "Owner commands installed.")
116107
} else {
@@ -119,8 +110,7 @@ pub(in crate::bot) async fn init(
119110
} else if api_key == "uninstall_owner_commands" {
120111
if check_owner(context).await? {
121112
context.data().db.set_owner_guild(guild_id, false).await?;
122-
util::set_guild_commands(&context, &context.data().db, guild_id, Some(false), None)
123-
.await?;
113+
util::set_guild_commands(&context, &context.data().db, guild_id, Some(false), None).await?;
124114
success_reply("Success", "Owner commands uninstalled.")
125115
} else {
126116
error_reply("Error Uninstalling Owner Commands", "Not an owner")
@@ -136,20 +126,15 @@ pub(in crate::bot) async fn init(
136126
.db
137127
.set_jinxxy_api_key(guild_id, api_key.to_string())
138128
.await?;
139-
util::set_guild_commands(&context, &context.data().db, guild_id, None, Some(true))
140-
.await?;
129+
util::set_guild_commands(&context, &context.data().db, guild_id, None, Some(true)).await?;
141130
let reply = success_reply(
142131
"Success",
143132
format!(
144133
"Welcome, {display_name}! API key set and additional slash commands enabled. Please continue bot setup."
145134
),
146135
);
147136
if has_required_scopes {
148-
context
149-
.data()
150-
.api_cache
151-
.register_guild_in_cache(guild_id)
152-
.await?;
137+
context.data().api_cache.register_guild_in_cache(guild_id).await?;
153138
reply
154139
} else {
155140
debug!("nagged about API key scopes in {}", guild_id.get());
@@ -160,18 +145,11 @@ pub(in crate::bot) async fn init(
160145
reply.embed(embed)
161146
}
162147
}
163-
Err(e) => error_reply(
164-
"Error Initializing Jinx",
165-
format!("Error verifying API key: {e}"),
166-
),
148+
Err(e) => error_reply("Error Initializing Jinx", format!("Error verifying API key: {e}")),
167149
}
168150
} else {
169151
// user has given us some mystery garbage value for their API key
170-
debug!(
171-
"invalid API key provided in {}: \"{}\"",
172-
guild_id.get(),
173-
api_key
174-
); // log it to try and diagnose why people have trouble with the initial setup
152+
debug!("invalid API key provided in {}: \"{}\"", guild_id.get(), api_key); // log it to try and diagnose why people have trouble with the initial setup
175153
error_reply(
176154
"Error Initializing Jinx",
177155
"Provided API key appears to be invalid. API keys should look like `sk_9bba2064ee8c20aa4fd6b015eed2001a`. If you need help, bot setup documentation can be found [here](<https://github.com/zkxs/jinx#installation>).",

0 commit comments

Comments
 (0)