diff --git a/config/JSON/strings.json b/config/JSON/strings.json index 0ee23cb..1bed510 100644 --- a/config/JSON/strings.json +++ b/config/JSON/strings.json @@ -109,8 +109,6 @@ "error_no_case_found_description": "no case found with that ID.", "error_no_private_message_author": "Guild Only", "error_no_private_message_description": "this command can only be used in servers.", - "error_not_allowed_in_channel_author": "Not Allowed In Channel", - "error_not_allowed_in_channel_description": "you can only use that command in {0}.", "error_not_owner_author": "Owner Only", "error_not_owner_description": "this command requires Lumi ownership permissions.", "error_private_message_only_author": "Private Message Only", diff --git a/handlers/error_handler.py b/handlers/error_handler.py index d1c4a19..5b0a821 100644 --- a/handlers/error_handler.py +++ b/handlers/error_handler.py @@ -66,13 +66,6 @@ async def on_command_error(ctx, error): str(error), ) - elif isinstance(error, LumiExceptions.NotAllowedInChannel): - author_text = CONST.STRINGS["error_not_allowed_in_channel_author"] - description = CONST.STRINGS["error_not_allowed_in_channel_description"].format( - error.command_channel.mention, - ) - ephemeral = True - else: author_text = CONST.STRINGS["error_unknown_error_author"] description = CONST.STRINGS["error_unknown_error_description"] @@ -111,8 +104,6 @@ class ErrorListener(Cog): @Cog.listener() async def on_command_error(self, ctx, error) -> None: - if isinstance(error, LumiExceptions.NotAllowedInChannel): - return await on_command_error(ctx, error) await self.log_command_error(ctx, error, ".") diff --git a/lib/checks.py b/lib/checks.py index 638e7a7..c38e1de 100644 --- a/lib/checks.py +++ b/lib/checks.py @@ -17,25 +17,3 @@ def birthdays_enabled(): return True return commands.check(predicate) - - -def allowed_in_channel(): - async def predicate(ctx): - if ctx.guild is None: - return True - - guild_config = GuildConfig(ctx.guild.id) - command_channel_id = guild_config.command_channel_id - - if command_channel_id: - command_channel = await ctx.bot.get_or_fetch_channel( - ctx.guild, - command_channel_id, - ) - - if ctx.channel.id != command_channel_id and command_channel: - raise LumiExceptions.NotAllowedInChannel(command_channel) - - return True - - return commands.check(predicate) diff --git a/lib/exceptions/LumiExceptions.py b/lib/exceptions/LumiExceptions.py index 84eda9c..6fe96c6 100644 --- a/lib/exceptions/LumiExceptions.py +++ b/lib/exceptions/LumiExceptions.py @@ -1,15 +1,6 @@ from discord.ext import commands -class NotAllowedInChannel(commands.CheckFailure): - """ - Raised when checks.allowed_in_channel() fails. - """ - - def __init__(self, commands_channel): - self.command_channel = commands_channel - - class BirthdaysDisabled(commands.CheckFailure): """ Raised when the birthdays module is disabled in ctx.guild. diff --git a/modules/economy/__init__.py b/modules/economy/__init__.py index 9b63859..d6dcf19 100644 --- a/modules/economy/__init__.py +++ b/modules/economy/__init__.py @@ -1,7 +1,5 @@ import discord from discord.ext import bridge, commands - -from lib import checks from modules.economy import balance, blackjack, daily, give, slots @@ -18,7 +16,6 @@ class Economy(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() @commands.cooldown(1, 10, commands.BucketType.user) async def balance_command(self, ctx): return await balance.cmd(ctx) @@ -31,7 +28,6 @@ class Economy(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() async def blackjack_command(self, ctx, *, bet: int): return await blackjack.cmd(ctx, bet) @@ -43,7 +39,6 @@ class Economy(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() async def daily_command(self, ctx): return await daily.cmd(ctx) @@ -53,7 +48,6 @@ class Economy(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() async def give_command(self, ctx, *, user: discord.Member, amount: int): return await give.cmd(ctx, user, amount) @@ -62,7 +56,6 @@ class Economy(commands.Cog): help="Give a server member some cash. You can use ID or mention them.", ) @commands.guild_only() - @checks.allowed_in_channel() async def give_command_prefixed(self, ctx, user: discord.User, *, amount: int): try: member = await ctx.guild.fetch_member(user.id) @@ -79,7 +72,6 @@ class Economy(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() @commands.cooldown(1, 5, commands.BucketType.user) async def slots_command(self, ctx, *, bet: int): return await slots.cmd(self, ctx, bet) diff --git a/modules/levels/__init__.py b/modules/levels/__init__.py index 93a6af4..4dd5c27 100644 --- a/modules/levels/__init__.py +++ b/modules/levels/__init__.py @@ -1,6 +1,5 @@ from discord.ext import bridge, commands -from lib import checks from modules.levels import leaderboard, level @@ -16,7 +15,6 @@ class Levels(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() @commands.cooldown(1, 30, commands.BucketType.user) async def level_command(self, ctx) -> None: await level.rank(ctx) @@ -29,7 +27,6 @@ class Levels(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() @commands.cooldown(1, 180, commands.BucketType.user) async def leaderboard_command(self, ctx) -> None: await leaderboard.cmd(ctx) diff --git a/modules/misc/__init__.py b/modules/misc/__init__.py index 2217515..60f39e6 100644 --- a/modules/misc/__init__.py +++ b/modules/misc/__init__.py @@ -5,7 +5,6 @@ from discord.commands import SlashCommandGroup from discord.ext import bridge, commands, tasks from Client import LumiBot -from lib import checks from modules.config import c_prefix from modules.misc import avatar, backup, info, introduction, invite, ping, xkcd @@ -28,7 +27,6 @@ class Misc(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() async def avatar(self, ctx, user: discord.Member) -> None: return await avatar.get_avatar(ctx, user) @@ -38,7 +36,6 @@ class Misc(commands.Cog): description="Simple status check.", help="Simple status check.", ) - @checks.allowed_in_channel() async def ping(self, ctx) -> None: await ping.ping(self, ctx) @@ -47,7 +44,6 @@ class Misc(commands.Cog): description="See Lumi's uptime since the last update.", help="See how long Lumi has been online since his last update.", ) - @checks.allowed_in_channel() async def uptime(self, ctx) -> None: await ping.uptime(self, ctx, self.start_time) @@ -56,7 +52,6 @@ class Misc(commands.Cog): description="Generate an invite link.", help="Generate a link to invite Lumi to your own server!", ) - @checks.allowed_in_channel() async def invite_command(self, ctx) -> None: await invite.cmd(ctx) @@ -67,7 +62,6 @@ class Misc(commands.Cog): guild_only=True, ) @commands.guild_only() - @checks.allowed_in_channel() async def prefix_command(self, ctx) -> None: await c_prefix.get_prefix(ctx) @@ -77,7 +71,6 @@ class Misc(commands.Cog): description="Shows basic Lumi stats.", help="Shows basic Lumi stats.", ) - @checks.allowed_in_channel() async def info_command(self, ctx) -> None: unix_timestamp: int = int(round(self.start_time.timestamp())) await info.cmd(self, ctx, unix_timestamp)