Permissions updates
This commit is contained in:
parent
cfa9642fb3
commit
9a3c86815d
8 changed files with 89 additions and 78 deletions
|
@ -7,6 +7,7 @@ from discord_slash.utils.manage_commands import create_option
|
|||
|
||||
from jarvis.db.types import Lock
|
||||
from jarvis.utils.cachecog import CacheCog
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class LockCog(CacheCog):
|
||||
|
@ -65,7 +66,7 @@ class LockCog(CacheCog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_channels=True)
|
||||
async def _lock(
|
||||
self,
|
||||
ctx: SlashContext,
|
||||
|
@ -111,7 +112,7 @@ class LockCog(CacheCog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_channels=True)
|
||||
async def _unlock(
|
||||
self,
|
||||
ctx: SlashContext,
|
||||
|
|
|
@ -9,6 +9,7 @@ from jarvis.config import get_config
|
|||
from jarvis.db import DBManager
|
||||
from jarvis.db.types import Lock
|
||||
from jarvis.utils.cachecog import CacheCog
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class LockdownCog(CacheCog):
|
||||
|
@ -35,7 +36,7 @@ class LockdownCog(CacheCog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_channels=True)
|
||||
async def _lockdown_start(
|
||||
self,
|
||||
ctx: SlashContext,
|
||||
|
|
|
@ -11,6 +11,7 @@ from jarvis.db.types import MongoSort, Warning
|
|||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.cachecog import CacheCog
|
||||
from jarvis.utils.field import Field
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class WarningCog(CacheCog):
|
||||
|
@ -41,7 +42,7 @@ class WarningCog(CacheCog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _warn(
|
||||
self, ctx: SlashContext, user: User, reason: str, duration: int = 24
|
||||
):
|
||||
|
@ -99,7 +100,7 @@ class WarningCog(CacheCog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _warnings(self, ctx: SlashContext, user: User, active: bool = 1):
|
||||
active = bool(active)
|
||||
exists = self.check_cache(ctx, user_id=user.id, active=active)
|
||||
|
@ -132,7 +133,7 @@ class WarningCog(CacheCog):
|
|||
else:
|
||||
fields = []
|
||||
for warn in active_warns:
|
||||
admin = ctx.guild.get(warn.admin)
|
||||
admin = ctx.guild.get_member(warn.admin)
|
||||
admin_name = "||`[redacted]`||"
|
||||
if admin:
|
||||
admin_name = f"{admin.name}#{admin.discriminator}"
|
||||
|
|
|
@ -8,6 +8,7 @@ from discord_slash.utils.manage_commands import create_option
|
|||
|
||||
from jarvis.data.unicode import emoji_list
|
||||
from jarvis.db.types import Autoreact
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class AutoReactCog(commands.Cog):
|
||||
|
@ -28,7 +29,7 @@ class AutoReactCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _autoreact_create(self, ctx: SlashContext, channel: TextChannel):
|
||||
if not isinstance(channel, TextChannel):
|
||||
await ctx.send("Channel must be a text channel", hidden=True)
|
||||
|
@ -62,6 +63,7 @@ class AutoReactCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _autoreact_delete(self, ctx, channel: TextChannel):
|
||||
exists = Autoreact.get(guild=ctx.guild.id, channel=channel.id).delete()
|
||||
if exists:
|
||||
|
@ -90,7 +92,7 @@ class AutoReactCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _autoreact_add(self, ctx, channel: TextChannel, emote: str):
|
||||
await ctx.defer()
|
||||
custom_emoji = self.custom_emote.match(emote)
|
||||
|
@ -152,7 +154,7 @@ class AutoReactCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _autoreact_remove(self, ctx, channel: TextChannel, emote: str):
|
||||
exists = Autoreact.get(guild=ctx.guild.id, channel=channel.id)
|
||||
if not exists:
|
||||
|
@ -185,7 +187,7 @@ class AutoReactCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _autoreact_list(self, ctx, channel: TextChannel):
|
||||
exists = Autoreact.get(guild=ctx.guild.id, channel=channel.id)
|
||||
if not exists:
|
||||
|
|
|
@ -368,6 +368,7 @@ class GitlabCog(CacheCog):
|
|||
|
||||
self.cache[hash(paginator)] = {
|
||||
"user": ctx.author.id,
|
||||
"guild": ctx.guild.id,
|
||||
"timeout": datetime.utcnow() + timedelta(minutes=5),
|
||||
"command": ctx.subcommand_name,
|
||||
"state": state,
|
||||
|
@ -459,6 +460,7 @@ class GitlabCog(CacheCog):
|
|||
|
||||
self.cache[hash(paginator)] = {
|
||||
"user": ctx.author.id,
|
||||
"guild": ctx.guild.id,
|
||||
"timeout": datetime.utcnow() + timedelta(minutes=5),
|
||||
"command": ctx.subcommand_name,
|
||||
"state": state,
|
||||
|
@ -528,6 +530,7 @@ class GitlabCog(CacheCog):
|
|||
|
||||
self.cache[hash(paginator)] = {
|
||||
"user": ctx.author.id,
|
||||
"guild": ctx.guild.id,
|
||||
"timeout": datetime.utcnow() + timedelta(minutes=5),
|
||||
"command": ctx.subcommand_name,
|
||||
"paginator": paginator,
|
||||
|
|
|
@ -6,6 +6,7 @@ from discord_slash.utils.manage_commands import create_option
|
|||
from jarvis.db.types import Setting
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.field import Field
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
|
||||
class RolegiverCog(commands.Cog):
|
||||
|
@ -25,7 +26,7 @@ class RolegiverCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _rolegiver_add(self, ctx: SlashContext, role: Role):
|
||||
setting = Setting.get(guild=ctx.guild.id, setting="rolegiver")
|
||||
if setting and role.id in setting.value:
|
||||
|
@ -82,7 +83,7 @@ class RolegiverCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _rolegiver_remove(self, ctx: SlashContext, role: Role):
|
||||
setting = Setting.get(guild=ctx.guild.id, setting="rolegiver")
|
||||
if not setting or (setting and not setting.value):
|
||||
|
|
|
@ -30,7 +30,7 @@ class SettingsCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@admin_or_permissions(mute_members=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _mute(self, ctx, role: Role):
|
||||
await ctx.defer()
|
||||
self.update_settings("mute", role.id, ctx.guild.id)
|
||||
|
@ -49,7 +49,7 @@ class SettingsCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _modlog(self, ctx, channel: TextChannel):
|
||||
if not isinstance(channel, TextChannel):
|
||||
await ctx.send("Channel must be a TextChannel", hidden=True)
|
||||
|
@ -72,7 +72,7 @@ class SettingsCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _userlog(self, ctx, channel: TextChannel):
|
||||
if not isinstance(channel, TextChannel):
|
||||
await ctx.send("Channel must be a TextChannel", hidden=True)
|
||||
|
@ -95,7 +95,7 @@ class SettingsCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _massmention(self, ctx, amount: int):
|
||||
await ctx.defer()
|
||||
self.update_settings("massmention", amount, ctx.guild.id)
|
||||
|
@ -114,7 +114,7 @@ class SettingsCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@admin_or_permissions(kick_members=True, ban_members=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _verified(self, ctx, role: Role):
|
||||
await ctx.defer()
|
||||
self.update_settings("verified", role.id, ctx.guild.id)
|
||||
|
@ -133,7 +133,7 @@ class SettingsCog(commands.Cog):
|
|||
)
|
||||
],
|
||||
)
|
||||
@admin_or_permissions(kick_members=True, ban_members=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _unverified(self, ctx, role: Role):
|
||||
await ctx.defer()
|
||||
self.update_settings("unverified", role.id, ctx.guild.id)
|
||||
|
|
|
@ -5,6 +5,7 @@ from discord_slash.utils.manage_commands import create_option
|
|||
|
||||
from jarvis.db.types import Star, Starboard
|
||||
from jarvis.utils import build_embed
|
||||
from jarvis.utils.permissions import admin_or_permissions
|
||||
|
||||
supported_images = [
|
||||
"image/png",
|
||||
|
@ -24,7 +25,7 @@ class StarboardCog(commands.Cog):
|
|||
name="list",
|
||||
description="Lists all Starboards",
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _list(self, ctx):
|
||||
starboards = Starboard.get_many(guild=ctx.guild.id)
|
||||
if starboards != []:
|
||||
|
@ -48,7 +49,7 @@ class StarboardCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _create(self, ctx, channel: TextChannel):
|
||||
if channel not in ctx.guild.channels:
|
||||
await ctx.send(
|
||||
|
@ -88,7 +89,7 @@ class StarboardCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _delete(self, ctx, channel: TextChannel):
|
||||
deleted = Starboard.get(
|
||||
channel=channel.id, guild=ctx.guild.id
|
||||
|
@ -129,7 +130,7 @@ class StarboardCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
@commands.has_permissions(administrator=True)
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _star_add(
|
||||
self,
|
||||
ctx: SlashContext,
|
||||
|
@ -240,7 +241,8 @@ class StarboardCog(commands.Cog):
|
|||
),
|
||||
],
|
||||
)
|
||||
async def _star_get(
|
||||
@admin_or_permissions(manage_server=True)
|
||||
async def _star_delete(
|
||||
self,
|
||||
ctx: SlashContext,
|
||||
id: int,
|
||||
|
|
Loading…
Add table
Reference in a new issue