Skip to content

Commit 03a558d

Browse files
authored
Fix invalid role configuration (#251)
* Catch invalid role configuration * Fix invalid role configuration
1 parent 3045a56 commit 03a558d

File tree

3 files changed

+10
-4
lines changed

3 files changed

+10
-4
lines changed

prod-config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pretix_cache_file = "pretix_cache.json"
1616
"Personal" = ["Participants", "Onsite Participants"]
1717
"Education" = ["Participants", "Onsite Participants"]
1818
"Community Contributors" = ["Participants", "Onsite Participants"]
19-
"Grant ticket" = ["PARTICIPANTS", "Onsite Participants"]
19+
"Grant ticket" = ["Participants", "Onsite Participants"]
2020
# remote participants
2121
"Remote Participation Ticket" = ["Participants", "Remote Participants"]
2222
"Remote Grant ticket" = ["Participants", "Remote Participants"]
@@ -27,7 +27,7 @@ pretix_cache_file = "pretix_cache.json"
2727
"Presenter" = ["Participants", "Onsite Participants", "Speakers"]
2828

2929
[registration.variation_to_roles]
30-
"Volunteer" = ["Volunteers"]
30+
"Volunteer" = ["Volunteers", "Onsite Volunteers"]
3131

3232
[program_notifications]
3333
# UTC offset in hours (e.g. 2 for CEST)

src/europython_discord/registration/cog.py

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -93,6 +93,12 @@ async def on_submit(self, interaction: discord.Interaction) -> None:
9393
await interaction.user.edit(nick=nickname)
9494

9595
roles = [discord_get(interaction.guild.roles, name=role_name) for role_name in role_names]
96+
if any(role is None for role in roles):
97+
await self.log_error_to_user(interaction, "Internal error, please contact us.")
98+
await self.log_error_to_channel(interaction, f"Found invalid role in {role_names}")
99+
_logger.error("At least one of the role names %s is invalid", role_names)
100+
return
101+
96102
_logger.info("Assigning %r role_names=%r", name, role_names)
97103
await interaction.user.add_roles(*roles)
98104

test-config.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ pretix_cache_file = "pretix_cache.json"
1616
"Personal" = ["Participants", "Onsite Participants"]
1717
"Education" = ["Participants", "Onsite Participants"]
1818
"Community Contributors" = ["Participants", "Onsite Participants"]
19-
"Grant ticket" = ["PARTICIPANTS", "Onsite Participants"]
19+
"Grant ticket" = ["Participants", "Onsite Participants"]
2020
# remote participants
2121
"Remote Participation Ticket" = ["Participants", "Remote Participants"]
2222
"Remote Grant ticket" = ["Participants", "Remote Participants"]
@@ -27,7 +27,7 @@ pretix_cache_file = "pretix_cache.json"
2727
"Presenter" = ["Participants", "Onsite Participants", "Speakers"]
2828

2929
[registration.variation_to_roles]
30-
"Volunteer" = ["Volunteers"]
30+
"Volunteer" = ["Volunteers", "Onsite Volunteers"]
3131

3232
[program_notifications]
3333
# UTC offset in hours (e.g. 2 for CEST)

0 commit comments

Comments
 (0)