Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix permission checks on starboard interactions & manage_cogs #176

Merged
merged 1 commit into from
Nov 8, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

7 changes: 4 additions & 3 deletions uqcsbot/manage_cogs.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,19 @@
from discord.ext import commands

from uqcsbot.yelling import yelling_exemptor
from uqcsbot.bot import UQCSBot


class ManageCogs(commands.Cog):
"""
Note that most of these commands can make the bot load files to execute. Care should be made to ensure only entrusted users have access.
"""

def __init__(self, bot: commands.Bot):
def __init__(self, bot: UQCSBot):
self.bot = bot

@app_commands.command(name="managecogs")
@app_commands.default_permissions(manage_guild=True)
@app_commands.checks.has_permissions(manage_guild=True)
@app_commands.describe(
cog='The cog (i.e. python file) to try to unload. Use python package notation, so no suffix of ".py" and "." between folders: e.g. "manage_cogs".',
)
Expand Down Expand Up @@ -49,5 +50,5 @@ async def manage_cogs(
await self.bot.tree.sync()


async def setup(bot: commands.Bot):
async def setup(bot: UQCSBot):
await bot.add_cog(ManageCogs(bot))
7 changes: 3 additions & 4 deletions uqcsbot/starboard.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,15 +62,14 @@ async def on_ready(self):
)

@app_commands.command()
@app_commands.default_permissions(manage_guild=True)
@app_commands.checks.has_permissions(manage_guild=True)
async def cleanup_starboard(self, interaction: discord.Interaction):
"""Cleans up the last 100 messages from the starboard.
Removes any uqcsbot message that doesn't have a corresponding message id in the db, regardless of recv.
Otherwise, causes a starboard update on the messages.

manage_guild perms: for committee and infra use.
"""

if interaction.channel == self.starboard_channel:
# because if you do it from in the starboard, it deletes its own interaction response
# and i cba making it not do that, so i'll just forbid doing it in starboard.
Expand Down Expand Up @@ -146,7 +145,7 @@ async def _blacklist_log(
)
)

@app_commands.default_permissions(manage_messages=True)
@app_commands.checks.has_permissions(manage_messages=True)
async def context_blacklist_sb_message(
self, interaction: discord.Interaction, message: discord.Message
):
Expand Down Expand Up @@ -194,7 +193,7 @@ async def context_blacklist_sb_message(
f"Blacklisted message {message.id}.", ephemeral=True
)

@app_commands.default_permissions(manage_messages=True)
@app_commands.checks.has_permissions(manage_messages=True)
async def context_unblacklist_sb_message(
self, interaction: discord.Interaction, message: discord.Message
):
Expand Down
Loading