#How to check if a user is Online?

1 messages Β· Page 1 of 1 (latest)

fickle halo
#

How to check if a user is Online? I tried looking on the web but I didn't find anything (that worked)

here is what I tried

if user.status == discord.Status.online:

I don't even get any errors, it just shows that everyone is offline

snow bane
#

do you have the presences intent enabled in the application page and code?

fickle halo
#

I have everything enabled

#

my code wouldnt work without intents

#
intents = discord.Intents().all()

prefix = "$p "
client = commands.Bot(command_prefix=prefix, intents=intents)
fickle halo
#

@snow bane

snow bane
#

dont ping

#

also i have no clue

fickle halo
#

ok

modest sentinel
#

any code?

fickle halo
#

what code

modest sentinel
#

are you using that inside a command

modest sentinel
fickle halo
#

yes

#
@client.user_command(guild_ids=[972791561450573824], name="Pickpocket", pass_context=True)
async def pickpocket(ctx, user: discord.Member):
    if ctx.author == user:
        await ctx.respond("You cannot rob yourself!")
    else:
        if user.status is discord.Status.online:

            # Check for the account of the author and of the user that is robbed
            await config.open_account(ctx.author)
            await config.open_account(user)
            bal = await config.get_specific_bank_data(user)
            robber = await config.get_specific_bank_data(ctx.author)

            # Check if the robber or the author has less  than 75k money
            if int(bal[0]) < 75000:
                await ctx.respond("The user has less than 75,000🍌!")
                return

            if int(robber[0]) < 75000:
                await ctx.respond("You need to have atleast 75,000🍌 to use this command!")
                return

            # Get the skill of the authro
            skill = await config.get_specific_user_skills(ctx.author, type="stealing")


            # Calculate the amount of cash to steal from the player
            if skill["level"] / 5 < 1:
                earnings = (random.randint(700, 3000) * (bal[0] / 10000)) / 100
            else:
                earnings = ((random.randint(700, 3000) * (bal[0] / 10000)) * skill["level"] / 5) / 100

            earnings = round(earnings)

            await config.update_bank_data(user, -1 * earnings, "wallet")
            await config.update_bank_data(ctx.author, earnings, "wallet")
            await ctx.respond(f"You stole {earnings}🍌")

        else:
            await ctx.respond("The user you are trying to steal from isn't Online!")
modest sentinel
#

lemme check smth πŸ’€

fickle halo
#

what πŸ’€

modest sentinel
#

works for me mm

fickle halo
#

huh