Skip to content

Commit 2d52682

Browse files
committed
Fix notes reader/writer in an actually smart way
1 parent e7f6785 commit 2d52682

1 file changed

Lines changed: 3 additions & 16 deletions

File tree

techsupport_bot/commands/notes.py

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -110,22 +110,7 @@ async def is_writer(interaction: discord.Interaction) -> bool:
110110
bool: True if the user can run, False if they cannot
111111
"""
112112
config = interaction.client.guild_configs[str(interaction.guild.id)]
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 as e:
119-
raise app_commands.MissingAnyRole(reader_roles) from e
120-
except app_commands.AppCommandError as e:
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) from e
127-
128-
if writer_roles:
113+
if writer_roles := config.extensions.notes.note_writers.value:
129114
roles = (
130115
discord.utils.get(interaction.guild.roles, name=role)
131116
for role in writer_roles
@@ -156,6 +141,7 @@ class Notes(cogs.BaseCog):
156141
name="notes", description="Command Group for the Notes Extension"
157142
)
158143

144+
@app_commands.check(is_reader)
159145
@app_commands.check(is_writer)
160146
@notes.command(
161147
name="set",
@@ -225,6 +211,7 @@ async def set_note(
225211
embed = auxiliary.prepare_confirm_embed(message=f"Note created for `{user}`")
226212
await interaction.response.send_message(embed=embed, ephemeral=True)
227213

214+
@app_commands.check(is_reader)
228215
@app_commands.check(is_writer)
229216
@notes.command(
230217
name="clear",

0 commit comments

Comments
 (0)