Skip to content

Commit

Permalink
replace checks with better ones
Browse files Browse the repository at this point in the history
  • Loading branch information
No767 committed Jul 23, 2024
1 parent 600bb7d commit d360d20
Showing 1 changed file with 18 additions and 13 deletions.
31 changes: 18 additions & 13 deletions bot/cogs/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,11 @@
from discord.ext import commands, menus
from libs.tickets.utils import get_cached_thread
from libs.utils import GuildContext
from libs.utils.checks import bot_check_permissions, check_permissions
from libs.utils.checks import (
bot_check_permissions,
check_permissions,
is_manager,
)
from libs.utils.embeds import CooldownEmbed, Embed
from libs.utils.pages import SimplePages
from libs.utils.pages.paginator import RoboPages
Expand All @@ -33,6 +37,7 @@

if TYPE_CHECKING:
from cogs.tickets import Tickets

from rodhaj import Rodhaj


Expand Down Expand Up @@ -471,7 +476,7 @@ async def _handle_error(
elif isinstance(error, commands.BadArgument):
await ctx.send(str(error))

@check_permissions(manage_guild=True)
@is_manager()
@bot_check_permissions(manage_channels=True, manage_webhooks=True)
@commands.guild_only()
@commands.group(name="rodhaj")
Expand All @@ -480,7 +485,7 @@ async def rodhaj(self, ctx: GuildContext) -> None:
if ctx.invoked_subcommand is None:
await ctx.send_help(ctx.command)

@check_permissions(manage_guild=True)
@is_manager()
@bot_check_permissions(manage_channels=True, manage_webhooks=True)
@commands.cooldown(1, 20, commands.BucketType.guild)
@commands.guild_only()
Expand Down Expand Up @@ -644,7 +649,7 @@ async def setup(self, ctx: GuildContext, *, flags: SetupFlags) -> None:
msg = f"Rodhaj channels successfully created! The ticket channel can be found under {ticket_channel.mention}"
await ctx.send(msg)

@check_permissions(manage_guild=True)
@is_manager()
@bot_check_permissions(manage_channels=True, manage_webhooks=True)
@commands.cooldown(1, 20, commands.BucketType.guild)
@commands.guild_only()
Expand Down Expand Up @@ -710,15 +715,15 @@ async def on_delete_error(
) -> None:
await self._handle_error(error, ctx=ctx)

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@commands.hybrid_group(name="config")
async def config(self, ctx: GuildContext) -> None:
"""Modifiable configuration layer for Rodhaj"""
if ctx.invoked_subcommand is None:
await ctx.send_help(ctx.command)

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@config.command(name="options", usage="active: <bool>")
async def config_options(
Expand All @@ -742,7 +747,7 @@ async def config_options(
pages = ConfigPages(guild_settings.to_dict(), ctx=ctx, active=flags.active)
await pages.start()

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@config.command(name="set-age")
async def config_set_age(
Expand Down Expand Up @@ -772,7 +777,7 @@ async def config_set_age(
self.get_guild_settings.cache_invalidate(ctx.guild.id)
await ctx.send(f"Set `{type}_age` to `{duration.td}`")

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@config.command(name="set")
async def config_set(
Expand Down Expand Up @@ -800,7 +805,7 @@ async def config_set(

await self.set_guild_settings(key, value, config_type=ConfigType.SET, ctx=ctx)

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@config.command(name="toggle")
async def config_toggle(
Expand Down Expand Up @@ -845,7 +850,7 @@ async def on_config_toggle_error(
):
await self._handle_error(error, ctx=ctx)

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@config.group(name="prefix", fallback="info")
async def prefix(self, ctx: GuildContext) -> None:
Expand All @@ -862,7 +867,7 @@ async def prefix(self, ctx: GuildContext) -> None:
embed.set_author(name=ctx.guild.name, icon_url=ctx.guild.icon.url) # type: ignore
await ctx.send(embed=embed)

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@prefix.command(name="add")
@app_commands.describe(prefix="The new prefix to add")
Expand Down Expand Up @@ -891,7 +896,7 @@ async def prefix_add(
get_prefix.cache_invalidate(self.bot, ctx.message)
await ctx.send(f"Added prefix: `{prefix}`")

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@prefix.command(name="edit")
@app_commands.describe(
Expand Down Expand Up @@ -920,7 +925,7 @@ async def prefix_edit(
else:
await ctx.send("The prefix is not in the list of prefixes for your server")

@check_permissions(manage_guild=True)
@is_manager()
@commands.guild_only()
@prefix.command(name="delete")
@app_commands.describe(prefix="The prefix to delete")
Expand Down

0 comments on commit d360d20

Please sign in to comment.