Massive lint fix

This commit is contained in:
Natsu Kagami 2023-10-22 17:45:13 +02:00
parent 1a6039aa94
commit 54502ad61b
Signed by: nki
GPG key ID: 55A032EB38B49ADB
28 changed files with 117 additions and 122 deletions

View file

@ -32,7 +32,7 @@ pub async fn soft_ban(ctx: &Context, msg: &Message, mut args: Args) -> CommandRe
.guild_id
.ok_or_else(|| Error::msg("Command is guild only"))?;
let mut db = SoftBans::open(&*data);
let mut db = SoftBans::open(&data);
let val = db
.borrow()?
.get(&guild)
@ -85,13 +85,13 @@ pub async fn soft_ban(ctx: &Context, msg: &Message, mut args: Args) -> CommandRe
pub async fn soft_ban_init(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
let role_id = args.single::<RoleId>()?;
let data = ctx.data.read().await;
let guild = msg.guild(&ctx).unwrap();
let guild = msg.guild(ctx).unwrap();
// Check whether the role_id is the one we wanted
if !guild.roles.contains_key(&role_id) {
return Err(Error::msg(format!("{} is not a role in this server.", role_id)).into());
}
// Check if we already set up
let mut db = SoftBans::open(&*data);
let mut db = SoftBans::open(&data);
let set_up = db.borrow()?.contains_key(&guild.id);
if !set_up {
@ -111,7 +111,7 @@ pub async fn watch_soft_bans(cache_http: Arc<CacheAndHttp>, data: AppData) {
{
// Poll the data for any changes.
let data = data.read().await;
let mut data = SoftBans::open(&*data);
let mut data = SoftBans::open(&data);
let mut db = data.borrow().unwrap().clone();
let now = Utc::now();
for (server_id, bans) in db.iter_mut() {
@ -131,7 +131,7 @@ pub async fn watch_soft_bans(cache_http: Arc<CacheAndHttp>, data: AppData) {
.map(|user_id| {
bans.periodical_bans.remove(&user_id);
lift_soft_ban_for(
&*cache_http,
&cache_http,
*server_id,
&server_name[..],
bans.role,

View file

@ -62,7 +62,7 @@ pub async fn choose(ctx: &Context, m: &Message, mut args: Args) -> CommandResult
let online_only = !flags.contains("everyone");
let users: Result<Vec<_>, Error> = {
let guild = m.guild(&ctx).unwrap();
let guild = m.guild(ctx).unwrap();
let presences = &guild.presences;
let channel = m.channel_id.to_channel(&ctx).await?;
if let Channel::Guild(channel) = channel {

View file

@ -19,7 +19,7 @@ pub use reaction_watcher::Watchers as ReactionWatchers;
async fn list(ctx: &Context, m: &Message, _: Args) -> CommandResult {
let guild_id = m.guild_id.unwrap(); // only_in(guilds)
let data = ctx.data.read().await;
let db = DB::open(&*data);
let db = DB::open(&data);
let roles = db
.borrow()?
.get(&guild_id)
@ -190,7 +190,7 @@ async fn add(ctx: &Context, m: &Message, mut args: Args) -> CommandResult {
m.reply(&ctx, "No such role exists").await?;
}
Some(role) => {
DB::open(&*data)
DB::open(&data)
.borrow_mut()?
.entry(guild_id)
.or_default()
@ -227,7 +227,7 @@ async fn remove(ctx: &Context, m: &Message, mut args: Args) -> CommandResult {
m.reply(&ctx, "No such role exists").await?;
}
Some(role)
if !DB::open(&*data)
if !DB::open(&data)
.borrow()?
.get(&guild_id)
.map(|g| g.roles.contains_key(&role.id))
@ -237,7 +237,7 @@ async fn remove(ctx: &Context, m: &Message, mut args: Args) -> CommandResult {
.await?;
}
Some(role) => {
DB::open(&*data)
DB::open(&data)
.borrow_mut()?
.entry(guild_id)
.or_default()
@ -289,7 +289,7 @@ async fn parse(
let title = args.single_quoted::<String>().unwrap();
let data = ctx.data.read().await;
let guild_id = m.guild_id.unwrap();
let assignables = DB::open(&*data)
let assignables = DB::open(&data)
.borrow()?
.get(&guild_id)
.filter(|v| !v.roles.is_empty())
@ -369,7 +369,7 @@ async fn updaterolemessage(ctx: &Context, m: &Message, args: Args) -> CommandRes
{
data.get::<ReactionWatchers>()
.unwrap()
.setup(&mut *message, ctx.clone(), guild_id, title, roles)
.setup(&mut message, ctx.clone(), guild_id, title, roles)
.await?;
} else {
m.reply(&ctx, "Message does not come with a reaction handler")
@ -436,7 +436,7 @@ mod reaction_watcher {
impl Watchers {
pub fn new(data: &TypeMap) -> Result<Self> {
let init = Roles::open(&*data)
let init = Roles::open(data)
.borrow()?
.iter()
.flat_map(|(&guild, rs)| {
@ -510,7 +510,7 @@ mod reaction_watcher {
// Store the message into the list.
{
let data = ctx.data.read().await;
Roles::open(&*data)
Roles::open(&data)
.borrow_mut()?
.entry(guild)
.or_default()
@ -537,7 +537,7 @@ mod reaction_watcher {
message: MessageId,
) -> Result<bool> {
let data = ctx.data.read().await;
Roles::open(&*data)
Roles::open(&data)
.borrow_mut()?
.entry(guild)
.or_default()
@ -583,7 +583,7 @@ mod reaction_watcher {
}
};
eprintln!("{:?}", reaction);
if let Err(e) = Self::handle_reaction(&ctx, guild, message, &*reaction).await {
if let Err(e) = Self::handle_reaction(&ctx, guild, message, &reaction).await {
eprintln!("Handling {:?}: {}", reaction, e);
break;
}
@ -610,7 +610,7 @@ mod reaction_watcher {
return Ok(());
}
// Get the role list.
let role = Roles::open(&*data)
let role = Roles::open(&data)
.borrow()?
.get(&guild)
.ok_or_else(|| Error::msg("guild no longer has role list"))?

View file

@ -116,7 +116,7 @@ pub async fn vote(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult
// Collect reactions...
let user_reactions = panel
.await_reactions(&ctx)
.await_reactions(ctx)
.removed(true)
.timeout(*duration)
.build()

View file

@ -64,7 +64,7 @@ pub fn load_role_list(
match legacy::RolesV1::load_from_path(v1_path.as_ref()) {
Ok(v1) => {
Roles::insert_into(map, path)?;
*Roles::open(&map).borrow_mut()? = v1
*Roles::open(map).borrow_mut()? = v1
.get_data(true)?
.into_iter()
.map(|(guild, roles)| {

View file

@ -103,7 +103,7 @@ async fn get_image(
// Fix the tags: change whitespaces to +
let tags = tags.split_whitespace().collect::<Vec<_>>().join("_");
let req = client
.get(&format!(
.get(format!(
"https://danbooru.donmai.us/posts.json?tags=rating:{}+{}",
rating.to_string(),
tags

View file

@ -95,7 +95,7 @@ async fn pick(ctx: &Context, msg: &Message, mut args: Args) -> CommandResult {
.peekable();
// If we have the first argument as question, use it.
let question = match choices.peek() {
Some(ref q) if q.starts_with('?') => Some(q.replacen("?", "", 1) + "?"),
Some(q) if q.starts_with('?') => Some(q.replacen('?', "", 1) + "?"),
_ => None,
};
// If we have a question, that's not a choice.