#Slash cmd role check. Code works but throws error

1 messages · Page 1 of 1 (latest)

mortal sonnet
#

My code
API - Python3
import os

API - Interactions
import interactions
from interactions import (
Extension, BaseContext, SlashContext,
# errors, utils,
)

Load Modules
import Config.staff_config as staff_cfg
###############################################################################
from Logger import bot_logger
my_logger = bot_logger.init_logger(os.path.basename(file))
###############################################################################
my_role = int(staff_cfg.my_moderator_id)

class Moderator_Commands(Extension):
async def my_check(ctx: BaseContext):
return ctx.member.has_role(my_role)

@interactions.slash_command(
    name="moderator",
    description="Moderator Commands",
)
@interactions.check(my_check)
async def moderator(self, ctx: SlashContext):
    await ctx.send("You are a Moderator of this bot!", ephemeral=True)
lament bridgeBOT
#

Hey! Once your issue is solved, press the button below to close this thread!

mortal sonnet
#

08:04.51AM [ ERROR ] main.py [ 650] Ignoring exception in cmd /moderator:
Traceback (most recent call last):
File "C:\Users\Lucas\AppData\Roaming\Python\Python311\site-packages\interactions\client\client.py", line 1900, in dispatch_interaction
response = await callback
^^^^^^^^^^^^^^
File "C:\Users\Lucas\AppData\Roaming\Python\Python311\site-packages\interactions\client\client.py", line 1771, in run_slash_command
return await command(ctx, **ctx.kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lucas\AppData\Roaming\Python\Python311\site-packages\interactions\models\internal\command.py", line 124, in call
_
if await self._can_run(context):
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Users\Lucas\AppData\Roaming\Python\Python311\site-packages\interactions\models\internal\command.py", line 216, in _can_run
raise CommandCheckFailure(self, _c, context)
interactions.client.errors.CommandCheckFailure: (SlashCommand(max_concurrency=Missing, pre_run_callback=None, scopes=[1145222627548479528], auto_defer=Missing), <function Moderator_Commands.my_check at 0x000001F991D86840>, <interactions.models.internal.context.SlashContext object at 0x000001F991E43A10>)

The command works, just throws this error. Tried to write it a few different ways..
If I had to guess it is something with the default message. If you fail the check

I can see it picking up the right guild id but the hexa bit code part has me guessing..

tropic jackal
#

I've got the same problem here: #1155469145983426571 message

mortal sonnet
#

okay,, so it's not just me.. I don't really know enough if it's a bug or if I need to define a response to the check?

tropic jackal
#

yes, i also was unsure,so i break it down to an internal check command with is_owner() and the same result

mortal sonnet
#

or if it is because I am the server/bot owner.. regardless of roles..

#

even if I tell discord I have no roles..

#

API - Python3

import os

API - Interactions

import interactions
from interactions import (
Extension, SlashContext,
# errors, utils,
)

###############################################################################
from Logger import bot_logger
my_logger = bot_logger.init_logger(os.path.basename(file))
###############################################################################

class Owner_Commands(Extension):
@interactions.slash_command(
name="owner",
description="owner Command",
)
@interactions.check(interactions.is_owner())
async def base_command(self, ctx: SlashContext):
await ctx.send("You are the owner of the bot!", ephemeral=True)
###############################################################################

-------------------------------- END CODE --------------------------------

###############################################################################

#

I get no error with this

tropic jackal
#

interesting

#

but why my won't work

mortal sonnet
#

async def base_command(self, ctx: SlashContext):

tropic jackal
#

but, i'm not here to overtake your post with my issue 😄

mortal sonnet
#

async def base_command(ctx: SlashContext):

#

That will kill it

#

need self..

#

even though the example does not show it

#

^^ needs self

tropic jackal
#

async def adminpanel(self, ctx: SlashContext):

#

this is my def

#

within an extension, so self is needed to pass through this command

mortal sonnet
#

maybe we need to try to write it with out extensions?

tropic jackal
#

I dont think thats the solution, I cannot work without Extensions

mortal sonnet
#

i had issues with the task,, stuff too.. but i coded it the long way and it works

#

idk, why it would only work with UTC

tropic jackal
#

I think the developers should have take a look here into our problems

mortal sonnet
#

sound legit.. So legit, I hope it quits

tropic jackal
#

they are very responsive in here, its just take a little

mortal sonnet
#

what version of python you on?

tropic jackal
#

ArchLinux, Python 3.11 and ipy 5.10.0

mortal sonnet
tropic jackal
#

yes. 3.11.5

mortal sonnet
#

whats ipy? new to all of this?

tropic jackal
#

except OS we are on same version stack

mortal sonnet
#

Oooo i see.. now..

mortal sonnet
#

it clearly needs a int (role id)

but it says The Role or role id to check for

is their a way to make it check for the name instead?

tropic jackal
#

see the discussion in #1155469145983426571 message

#

it is expected

#

confirmed by devs

#

your code is fine, just ignore the exceptions or catch it by yourself to be silent

mortal sonnet
#

okay so build a error tracking system..