Skip to content

Commit 0c55b32

Browse files
committed
converts discord field to discord-id field
Signed-off-by: Nell Shamrell <[email protected]>
1 parent 4dd4d98 commit 0c55b32

File tree

2 files changed

+12
-12
lines changed

2 files changed

+12
-12
lines changed

src/schema.rs

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ pub(crate) struct Person {
5252
irc: Option<String>,
5353
#[serde(default)]
5454
email: EmailField,
55-
discord: Option<String>,
55+
discord_id: Option<String>,
5656
#[serde(default)]
5757
permissions: Permissions,
5858
}
@@ -92,8 +92,8 @@ impl Person {
9292
}
9393
}
9494

95-
pub(crate) fn discord(&self) -> Option<&str> {
96-
self.discord.as_deref()
95+
pub(crate) fn discord_id(&self) -> Option<&str> {
96+
self.discord_id.as_deref()
9797
}
9898

9999
pub(crate) fn permissions(&self) -> &Permissions {

src/validate.rs

Lines changed: 9 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -17,7 +17,7 @@ static CHECKS: &[fn(&Data, &mut Vec<String>)] = &[
1717
validate_list_extra_teams,
1818
validate_list_addresses,
1919
validate_people_addresses,
20-
validate_discord_name,
20+
validate_discord_id,
2121
validate_duplicate_permissions,
2222
validate_permissions,
2323
validate_rfcbot_labels,
@@ -268,17 +268,17 @@ fn validate_people_addresses(data: &Data, errors: &mut Vec<String>) {
268268
});
269269
}
270270

271-
/// Ensure the Discord name is formatted properly
272-
fn validate_discord_name(data: &Data, errors: &mut Vec<String>) {
273-
// https://discordapp.com/developers/docs/resources/user#usernames-and-nicknames
274-
let name_re = Regex::new(r"^[^@#:`]{2,32}#[0-9]{4}$").unwrap();
271+
/// Ensure the Discord id is formatted properly
272+
fn validate_discord_id(data: &Data, errors: &mut Vec<String>) {
273+
// A Discord ID is 18 digits
274+
let id_re = Regex::new(r"^[0-9]{18}$").unwrap();
275275
wrapper(data.people(), errors, |person, _| {
276-
if let Some(name) = person.discord() {
277-
if !name_re.is_match(name) {
276+
if let Some(id) = person.discord_id() {
277+
if !id_re.is_match(id) {
278278
bail!(
279-
"user `{}` has an invalid discord name: {}",
279+
"user `{}` has an invalid discord id: {}",
280280
person.github(),
281-
name
281+
id
282282
);
283283
}
284284
}

0 commit comments

Comments
 (0)