#For some reason the event is later than the command

1 messages · Page 1 of 1 (latest)

compact oasis
#
from disnake.ext import commands

bot = commands.Bot(command_prefix="!")

@bot.event
async def on_ready():
    print(f'Logged in as {bot.user.name}')

bot.load_extension("cogs.event.new_users")

@bot.slash_command()
async def test(inter):

    print("HM2")


bot.run("token")
from disnake.ext import commands


class AddUsersDataBase(commands.Cog):
    def __init__(self, bot: commands.Bot):
        self.bot = bot

    @commands.Cog.listener()
    async def on_slash_command(self, user):
        
        print("HM1")


def setup(bot: commands.Bot):
    bot.add_cog(AddUsersDataBase(bot))

tells me

HM2
HM1
#

should output

HM1
HM2

meaning that the event occurred before the command, is there a way to fix this?

cinder surge
#

Well, the way to do it would be a before_invoke
on_slash_command is more or less just "Hey, a slash command was just invoked/is about to be invoked." It's not really useful for what I think you're trying to do.

#

But also, user is going to be disnake.ApplicationCommandInteraction It's not going to be any type of user/member object.

#

Also, if you're not planning to use prefix commands, switch to commands.InteractionBot