From 6a8c8f32ae641cdb6fd4a71103adcf869147462f Mon Sep 17 00:00:00 2001 From: Nawaf <30420446+xLive@users.noreply.github.com> Date: Tue, 26 Aug 2025 23:49:10 +0300 Subject: [PATCH 1/2] object: reply when command used in disallowed channel --- object/object.py | 20 ++++++++++++++++++-- 1 file changed, 18 insertions(+), 2 deletions(-) diff --git a/object/object.py b/object/object.py index 2104fef1..b228c02f 100644 --- a/object/object.py +++ b/object/object.py @@ -9,7 +9,7 @@ class Object(commands.Cog): def __init__(self, bot): self.bot = bot self.config = Config.get_conf(self, identifier=707350954969792584) - default_guild = {"channels": []} + default_guild = {"channels": [], "bot_channel": None} self.config.register_guild(**default_guild) self.url = "https://dev.prineside.com/en/gtasa_samp_model_id/model/" self.image = "https://files.prineside.com/gtasa_samp_model_id/white/{}_w.jpg" @@ -20,6 +20,17 @@ async def object(self, ctx, id: int): # If not allowed channel return channels = await self.config.guild(ctx.guild).channels() if ctx.channel.id not in channels: + bot_channel_id = await self.config.guild(ctx.guild).bot_channel() + bot_channel_mention = None + if bot_channel_id: + bot_channel = ctx.guild.get_channel(bot_channel_id) + if bot_channel: + bot_channel_mention = bot_channel.mention + if bot_channel_mention: + await ctx.send(f"{ctx.author.mention} This channel is not allowed to use the `object` command. Please use {bot_channel_mention} instead.") + else: + await ctx.send(f"{ctx.author.mention} This channel is not allowed to use the `object` command.") + await ctx.message.delete() return async with ctx.typing(): # Get object info from webpage @@ -76,4 +87,9 @@ async def channel(self, ctx): else: channels.append(ctx.channel.id) await self.config.guild(ctx.guild).channels.set(channels) - await ctx.channel.send("Object command is now allowed in this channel.") \ No newline at end of file + await ctx.channel.send("Object command is now allowed in this channel.") + + @objectset.command(description="Set the bot channel to mention when command is used in disallowed channel") + async def botchannel(self, ctx, channel: discord.TextChannel): + await self.config.guild(ctx.guild).bot_channel.set(channel.id) + await ctx.send(f"Bot channel to mention set to {channel.mention}.") \ No newline at end of file From 54601e78ecf39c5a14761a133c7465e335a43902 Mon Sep 17 00:00:00 2001 From: Nawaf <30420446+xLive@users.noreply.github.com> Date: Tue, 26 Aug 2025 23:55:09 +0300 Subject: [PATCH 2/2] object: show friendly message for invalid input --- object/object.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/object/object.py b/object/object.py index b228c02f..b0ba67af 100644 --- a/object/object.py +++ b/object/object.py @@ -15,7 +15,7 @@ def __init__(self, bot): self.image = "https://files.prineside.com/gtasa_samp_model_id/white/{}_w.jpg" @commands.command() - async def object(self, ctx, id: int): + async def object(self, ctx, id: str): """Get the object info""" # If not allowed channel return channels = await self.config.guild(ctx.guild).channels() @@ -32,6 +32,11 @@ async def object(self, ctx, id: int): await ctx.send(f"{ctx.author.mention} This channel is not allowed to use the `object` command.") await ctx.message.delete() return + try: + id = int(id) + except ValueError: + await ctx.send(f"{ctx.author.mention} Please provide a valid object ID (number).") + return async with ctx.typing(): # Get object info from webpage url = self.url + str(id)