Removed deprecated checks imports from redbot.core.commands

Added proper imports from redbot.core.utils.mod
Updated all permission decorators to use admin_or_permissions
This commit is contained in:
pacnpal
2024-11-16 17:19:20 +00:00
parent 08d5dc56cf
commit 82244884db
3 changed files with 20 additions and 17 deletions

View File

@@ -1,7 +1,8 @@
"""Module for core archiver commands""" """Module for core archiver commands"""
import discord import discord
from redbot.core.commands import Context, hybrid_group, guild_only, checks from redbot.core.commands import Context, hybrid_group, guild_only
from redbot.core.utils.mod import admin_or_permissions
from discord import app_commands from discord import app_commands
import logging import logging
from ..response_handler import handle_response from ..response_handler import handle_response
@@ -22,7 +23,7 @@ def setup_archiver_commands(cog):
@archiver.command(name="enable") @archiver.command(name="enable")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
async def enable_archiver(ctx: Context): async def enable_archiver(ctx: Context):
"""Enable video archiving in this server.""" """Enable video archiving in this server."""
try: try:
@@ -44,7 +45,7 @@ def setup_archiver_commands(cog):
@archiver.command(name="disable") @archiver.command(name="disable")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
async def disable_archiver(ctx: Context): async def disable_archiver(ctx: Context):
"""Disable video archiving in this server.""" """Disable video archiving in this server."""
try: try:

View File

@@ -1,7 +1,8 @@
"""Module for database-related commands""" """Module for database-related commands"""
import discord import discord
from redbot.core.commands import Context, hybrid_group, hybrid_command, guild_only, checks from redbot.core.commands import Context, hybrid_group, hybrid_command, guild_only
from redbot.core.utils.mod import admin_or_permissions
from discord import app_commands from discord import app_commands
import logging import logging
from ..response_handler import handle_response from ..response_handler import handle_response
@@ -23,7 +24,7 @@ def setup_database_commands(cog):
@archivedb.command(name="enable") @archivedb.command(name="enable")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
async def enable_database(ctx: Context): async def enable_database(ctx: Context):
"""Enable the video archive database.""" """Enable the video archive database."""
try: try:
@@ -65,7 +66,7 @@ def setup_database_commands(cog):
@archivedb.command(name="disable") @archivedb.command(name="disable")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
async def disable_database(ctx: Context): async def disable_database(ctx: Context):
"""Disable the video archive database.""" """Disable the video archive database."""
try: try:

View File

@@ -1,7 +1,8 @@
"""Module for settings-related commands""" """Module for settings-related commands"""
import discord import discord
from redbot.core.commands import Context, hybrid_command, guild_only, checks from redbot.core.commands import Context, hybrid_command, guild_only
from redbot.core.utils.mod import admin_or_permissions
from discord import app_commands from discord import app_commands
import logging import logging
from ..response_handler import handle_response from ..response_handler import handle_response
@@ -13,7 +14,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setchannel") @cog.hybrid_command(name="setchannel")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(channel="The channel where archived videos will be stored") @app_commands.describe(channel="The channel where archived videos will be stored")
async def set_archive_channel(ctx: Context, channel: discord.TextChannel): async def set_archive_channel(ctx: Context, channel: discord.TextChannel):
"""Set the channel where archived videos will be stored.""" """Set the channel where archived videos will be stored."""
@@ -36,7 +37,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setlog") @cog.hybrid_command(name="setlog")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(channel="The channel where log messages will be sent") @app_commands.describe(channel="The channel where log messages will be sent")
async def set_log_channel(ctx: Context, channel: discord.TextChannel): async def set_log_channel(ctx: Context, channel: discord.TextChannel):
"""Set the channel where log messages will be sent.""" """Set the channel where log messages will be sent."""
@@ -59,7 +60,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="addchannel") @cog.hybrid_command(name="addchannel")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(channel="The channel to monitor for videos") @app_commands.describe(channel="The channel to monitor for videos")
async def add_enabled_channel(ctx: Context, channel: discord.TextChannel): async def add_enabled_channel(ctx: Context, channel: discord.TextChannel):
"""Add a channel to monitor for videos.""" """Add a channel to monitor for videos."""
@@ -92,7 +93,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="removechannel") @cog.hybrid_command(name="removechannel")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(channel="The channel to stop monitoring") @app_commands.describe(channel="The channel to stop monitoring")
async def remove_enabled_channel(ctx: Context, channel: discord.TextChannel): async def remove_enabled_channel(ctx: Context, channel: discord.TextChannel):
"""Remove a channel from video monitoring.""" """Remove a channel from video monitoring."""
@@ -125,7 +126,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setformat") @cog.hybrid_command(name="setformat")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(format="The video format to use (mp4, webm, or mkv)") @app_commands.describe(format="The video format to use (mp4, webm, or mkv)")
async def set_video_format(ctx: Context, format: str): async def set_video_format(ctx: Context, format: str):
"""Set the video format for archived videos.""" """Set the video format for archived videos."""
@@ -153,7 +154,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setquality") @cog.hybrid_command(name="setquality")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(quality="The video quality (144-4320)") @app_commands.describe(quality="The video quality (144-4320)")
async def set_video_quality(ctx: Context, quality: int): async def set_video_quality(ctx: Context, quality: int):
"""Set the video quality for archived videos.""" """Set the video quality for archived videos."""
@@ -182,7 +183,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setmaxsize") @cog.hybrid_command(name="setmaxsize")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(size="The maximum file size in MB (1-100)") @app_commands.describe(size="The maximum file size in MB (1-100)")
async def set_max_file_size(ctx: Context, size: int): async def set_max_file_size(ctx: Context, size: int):
"""Set the maximum file size for archived videos.""" """Set the maximum file size for archived videos."""
@@ -209,7 +210,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setmessageduration") @cog.hybrid_command(name="setmessageduration")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(hours="How long to keep messages in hours (0-168)") @app_commands.describe(hours="How long to keep messages in hours (0-168)")
async def set_message_duration(ctx: Context, hours: int): async def set_message_duration(ctx: Context, hours: int):
"""Set how long to keep archived messages.""" """Set how long to keep archived messages."""
@@ -238,7 +239,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="settemplate") @cog.hybrid_command(name="settemplate")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe( @app_commands.describe(
template="The message template to use. Available placeholders: {author}, {channel}, {original_message}" template="The message template to use. Available placeholders: {author}, {channel}, {original_message}"
) )
@@ -272,7 +273,7 @@ def setup_settings_commands(cog):
@cog.hybrid_command(name="setconcurrent") @cog.hybrid_command(name="setconcurrent")
@guild_only() @guild_only()
@checks.admin_or_permissions(administrator=True) @admin_or_permissions(administrator=True)
@app_commands.describe(count="Number of concurrent downloads (1-5)") @app_commands.describe(count="Number of concurrent downloads (1-5)")
async def set_concurrent_downloads(ctx: Context, count: int): async def set_concurrent_downloads(ctx: Context, count: int):
"""Set the number of concurrent downloads allowed.""" """Set the number of concurrent downloads allowed."""