Skip to content

Commit de96e6f

Browse files
committed
Really fix reader/writer roles in notes
1 parent 1f70d65 commit de96e6f

1 file changed

Lines changed: 18 additions & 4 deletions

File tree

techsupport_bot/commands/notes.py

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -109,16 +109,30 @@ async def is_writer(interaction: discord.Interaction) -> bool:
109109
Returns:
110110
bool: True if the user can run, False if they cannot
111111
"""
112-
await is_reader(interaction)
113112
config = interaction.client.guild_configs[str(interaction.guild.id)]
114-
if reader_roles := config.extensions.notes.note_writers.value:
113+
reader_roles = config.extensions.notes.note_readers.value
114+
writer_roles = config.extensions.notes.note_writers.value
115+
116+
try:
117+
await is_reader(interaction)
118+
except app_commands.MissingAnyRole:
119+
raise app_commands.MissingAnyRole(reader_roles)
120+
except app_commands.AppCommandError:
121+
message = "There aren't any `note_readers` roles set in the config!"
122+
embed = auxiliary.prepare_deny_embed(message=message)
123+
124+
await interaction.response.send_message(embed=embed, ephemeral=True)
125+
126+
raise app_commands.AppCommandError(message)
127+
128+
if writer_roles:
115129
roles = (
116130
discord.utils.get(interaction.guild.roles, name=role)
117-
for role in reader_roles
131+
for role in writer_roles
118132
)
119133
status = any((role in interaction.user.roles for role in roles))
120134
if not status:
121-
raise app_commands.MissingAnyRole(reader_roles)
135+
raise app_commands.MissingAnyRole(writer_roles)
122136
return True
123137

124138
# Reader_roles are empty (not set)

0 commit comments

Comments
 (0)