create guild data if not present. added a temp method to reattach channels to their guild data
This commit is contained in:
		
							
								
								
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							
							
						
						
									
										2
									
								
								Cargo.lock
									
									
									
										generated
									
									
									
								
							| @@ -1175,7 +1175,7 @@ dependencies = [ | |||||||
|  |  | ||||||
| [[package]] | [[package]] | ||||||
| name = "reminder_rs" | name = "reminder_rs" | ||||||
| version = "1.1.2" | version = "1.1.3" | ||||||
| dependencies = [ | dependencies = [ | ||||||
|  "Inflector", |  "Inflector", | ||||||
|  "async-trait", |  "async-trait", | ||||||
|   | |||||||
| @@ -1,6 +1,6 @@ | |||||||
| [package] | [package] | ||||||
| name = "reminder_rs" | name = "reminder_rs" | ||||||
| version = "1.1.2" | version = "1.1.3" | ||||||
| authors = ["jellywx <judesouthworth@pm.me>"] | authors = ["jellywx <judesouthworth@pm.me>"] | ||||||
| edition = "2018" | edition = "2018" | ||||||
|  |  | ||||||
|   | |||||||
| @@ -466,7 +466,7 @@ LIMIT | |||||||
|                         .unwrap() |                         .unwrap() | ||||||
|                         .as_secs(); |                         .as_secs(); | ||||||
|  |  | ||||||
|                     longhand_displacement(reminder.time as u64 - now) |                     longhand_displacement((reminder.time as u64).checked_sub(now).unwrap_or(0)) | ||||||
|                 } |                 } | ||||||
|             }; |             }; | ||||||
|  |  | ||||||
|   | |||||||
| @@ -360,6 +360,7 @@ impl Framework for RegexFramework { | |||||||
|                         .expect("Could not get SQLPool from data"); |                         .expect("Could not get SQLPool from data"); | ||||||
|  |  | ||||||
|                     let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap(); |                     let user_data = UserData::from_user(&msg.author, &ctx, &pool).await.unwrap(); | ||||||
|  |                     let guild_data = GuildData::from_guild(guild.clone(), &pool).await.unwrap(); | ||||||
|  |  | ||||||
|                     match check_self_permissions(&ctx, &guild, &channel).await { |                     match check_self_permissions(&ctx, &guild, &channel).await { | ||||||
|                         Ok(perms) => match perms { |                         Ok(perms) => match perms { | ||||||
| @@ -373,11 +374,13 @@ impl Framework for RegexFramework { | |||||||
|                                     msg.channel(&ctx).await.unwrap(), |                                     msg.channel(&ctx).await.unwrap(), | ||||||
|                                     &pool, |                                     &pool, | ||||||
|                                 ) |                                 ) | ||||||
|                                 .await; |                                 .await | ||||||
|  |                                 .unwrap(); | ||||||
|  |  | ||||||
|                                 if !command.can_blacklist |                                 // required due to a small bug resulting in some channels being detached from their guild ids | ||||||
|                                     || !channel_data.map(|c| c.blacklisted).unwrap_or(false) |                                 channel_data.update_guild_id(guild_data.id, &pool).await; | ||||||
|                                 { |  | ||||||
|  |                                 if !command.can_blacklist || !channel_data.blacklisted { | ||||||
|                                     let args = full_match |                                     let args = full_match | ||||||
|                                         .name("args") |                                         .name("args") | ||||||
|                                         .map(|m| m.as_str()) |                                         .map(|m| m.as_str()) | ||||||
|   | |||||||
| @@ -158,6 +158,19 @@ SELECT id, name, nudge, blacklisted, webhook_id, webhook_token, paused, paused_u | |||||||
|         } |         } | ||||||
|     } |     } | ||||||
|  |  | ||||||
|  |     pub async fn update_guild_id(&self, id: u32, pool: &MySqlPool) { | ||||||
|  |         sqlx::query!( | ||||||
|  |             " | ||||||
|  | UPDATE channels SET guild_id = ? WHERE id = ? | ||||||
|  |             ", | ||||||
|  |             id, | ||||||
|  |             self.id | ||||||
|  |         ) | ||||||
|  |         .execute(pool) | ||||||
|  |         .await | ||||||
|  |         .unwrap(); | ||||||
|  |     } | ||||||
|  |  | ||||||
|     pub async fn commit_changes(&self, pool: &MySqlPool) { |     pub async fn commit_changes(&self, pool: &MySqlPool) { | ||||||
|         sqlx::query!( |         sqlx::query!( | ||||||
|             " |             " | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user