Skip to content
This repository has been archived by the owner on May 10, 2024. It is now read-only.

Leaderboard command not working . No error No response #21

Closed
infinotiver opened this issue Nov 11, 2021 · 30 comments
Closed

Leaderboard command not working . No error No response #21

infinotiver opened this issue Nov 11, 2021 · 30 comments

Comments

@infinotiver
Copy link
Contributor

Leaderboard command not working . No error No response . Here is the code - (Same as yours)

@client.command(aliases = ["lb"])
async def leaderboard(ctx,x = 1):
    users = await get_bank_data()
    leader_board = {}
    total = []
    for user in users:
        name = int(user)
        total_amount = users[user]["wallet"] + users[user]["bank"]
        leader_board[total_amount] = name
        total.append(total_amount)

    total = sorted(total,reverse=True)    

    em = discord.Embed(title = f"Top {x} Richest People" , description = "This is decided on the basis of raw money in the bank and wallet",color = discord.Color(0xfa43ee))
    index = 1
    for amt in total:
        id_ = leader_board[amt]
        member = client.get_user(id_)
        name = member.name
        em.add_field(name = f"{index}. {name}" , value = f"{amt}",  inline = False)
        if index == x:
            break
        else:
            index += 1

    await ctx.send(embed = em)

There is no indentation errors too

@AyushSehrawat
Copy link
Owner

Well, it worked for me ( i didn't try now ). Try seeing json file ? How it is saving

@infinotiver
Copy link
Contributor Author

I don't know why it doesn't works for me , few commands do t ever work though there are no errors . Sorry for wasting your time

@AyushSehrawat
Copy link
Owner

I recommend you use mongodb ( or sql/postgresql ) for making a economy bot. You can use this as a reference and dbs are easier than json.

@AyushSehrawat
Copy link
Owner

I don't know why it doesn't works for me , few commands do t ever work though there are no errors . Sorry for wasting your time

debug them ?

@infinotiver infinotiver reopened this Nov 25, 2021
@infinotiver
Copy link
Contributor Author

infinotiver commented Nov 25, 2021

", line 94, in wrapped
    raise CommandInvokeError(exc) from exc
discord.ext.commands.errors.CommandInvokeError: Command raised an exception: AttributeError: 'NoneType' object has no attribute 'name'

This is the error coming

@infinotiver
Copy link
Contributor Author

The main problem is with member.id thing

@AyushSehrawat
Copy link
Owner

Check json file? Btw i suggest you create bot from scratch and use these as a idea of how to make :)

@infinotiver
Copy link
Contributor Author

Check json file? Btw i suggest you create bot from scratch and use these as a idea of how to make :)

it works now but the names come double of some people

@infinotiver
Copy link
Contributor Author

@AyushSehrawat btw how do I add a command of showing detailed information about the item

@infinotiver
Copy link
Contributor Author

Also can you help me make the following command better I want the bot to automatically take money back after a user takes loan for a period

owner = 900992402356043806
@client.command()
@commands.cooldown(1, 60*60*24*7, commands.BucketType.user)
async def loan(ctx, amount : int):

    loan_available = int(client.open_account(owner)['wallet'])

    if int(amount) <= loan_available:

      time.sleep(1)

      await ctx.channel.send('You have been given ' + ''.join(str(amount) + ". You will have to pay " + str((int(amount)+int(amount)*0.1)) +" baguttes within 2 weeks."))

      await update_bank(ctx.author,+1*amount,'bank')


      must_pay.update({ctx.author.name:str(amount)})

    else:

        time.sleep(2)

        await ctx.channel.send("You Can only request a loan within "+str(loan_available))

    # New asyncio code
    
    await asyncio.sleep(60*60*24*7) # Wait for 60*60*24*7 seconds

    # Here, just add the code to take the money away after 60*60*24*7 seconds

this is my code I just want to know how to make the must.pay_within I dont know how to define it

@AyushSehrawat
Copy link
Owner

It won't work.

  • Need better db , maybe like mongoDB or sql
  • Cooldown won't work. It will reset if you start the bot. Like if a user has 3 hours cooldown and you restart bot , it will be 0. Instead for loan you should save the final date/time in db and run a tasks ( https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html ) which will see if current time = saved time in db and perform action according to it.

@AyushSehrawat
Copy link
Owner

For detailed info abt item, add another key in dictionary ?

@infinotiver
Copy link
Contributor Author

No I want like if a person enters shop ferrari it should show a embed about it like dankmemer i Dont want to make too mny subcommands for it if there is a easier way

@infinotiver
Copy link
Contributor Author

It won't work.

  • Need better db , maybe like mongoDB or sql
  • Cooldown won't work. It will reset if you start the bot. Like if a user has 3 hours cooldown and you restart bot , it will be 0. Instead for loan you should save the final date/time in db and run a tasks ( https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html ) which will see if current time = saved time in db and perform action according to it.

Btw cant this be performed in json also lke save the money taken, time etc

@infinotiver
Copy link
Contributor Author

I will figure out

@AyushSehrawat
Copy link
Owner

It won't work.

  • Need better db , maybe like mongoDB or sql
  • Cooldown won't work. It will reset if you start the bot. Like if a user has 3 hours cooldown and you restart bot , it will be 0. Instead for loan you should save the final date/time in db and run a tasks ( https://discordpy.readthedocs.io/en/stable/ext/tasks/index.html ) which will see if current time = saved time in db and perform action according to it.

Btw cant this be performed in json also lke save the money taken, time etc

Json gets corrupt if many read/write. You can use them for loading data, but constantly writing data will corrupt.

Its free and easy to get a mongodb , you can try that.
Also i was changing this bot from scratch

@AyushSehrawat
Copy link
Owner

@prakarsh17 You can check new readme for how to get mongodb instead of json :)

@infinotiver
Copy link
Contributor Author

Yeah I saw it yesterday only and wanted to thank you , I have implemented mongodb as a beta/testing feature in my bot , I will use it in the future hopefully , btw I can also copy your code from leafy-bot and understand it and use it , leafy-bot is amazing . Btw you said you had left db so now how?

@AyushSehrawat
Copy link
Owner

AyushSehrawat commented Dec 23, 2021

leafy-bot is open source, so yea you can see but try to implement code your own way :) It will help you.. Also, wdym by Btw you said you had left db so now how? ?

@infinotiver
Copy link
Contributor Author

Q -Btw you said you had left db so now how?

A -

Um.. I no longer use dpy so bots deleted
https://github.com/AyushSehrawat/eco-bot/discussions/24

@AyushSehrawat
Copy link
Owner

Oh, this repo was getting pretty much attention ( i mean views, stars and forks ) so edited it. Previous code was my first bot code ;). This one is better.

Btw checkout my latest updates for buy and sell command :)

@AyushSehrawat
Copy link
Owner

Leaderbord and extra commands soon :)

@infinotiver
Copy link
Contributor Author

Oh, this repo was getting pretty much attention ( i mean views, stars and forks ) so edited it. Previous code was my first bot code ;). This one is better.

Btw checkout my latest updates for buy and sell command :)

Checking I think I should make a new bot i cant have two sys in one bot what u say , the json one is very big and grown so it is not worth replacing it

@infinotiver
Copy link
Contributor Author

one more thing , i need two more clusters isnt it so where to make it inside the first one or in the project where? I am new to it

@AyushSehrawat
Copy link
Owner

You can create another inside it. When you login in Mongodb and see your project clusters. There you can see Database Deployments. There create new. Or you can just create new project

@infinotiver
Copy link
Contributor Author

oh so you are online , are u on discord btw

@AyushSehrawat
Copy link
Owner

Oh, this repo was getting pretty much attention ( i mean views, stars and forks ) so edited it. Previous code was my first bot code ;). This one is better.
Btw checkout my latest updates for buy and sell command :)

Checking I think I should make a new bot i cant have two sys in one bot what u say , the json one is very big and grown so it is not worth replacing it

Creating new is better. Replace it when done

@infinotiver
Copy link
Contributor Author

ok pls tell your discord username

@AyushSehrawat
Copy link
Owner

AyushSehrawat commented Dec 24, 2021

Mini#5183

@AyushSehrawat
Copy link
Owner

@prakarsh17 https://discord.gg/gQ9rcuNK75 : For discord server

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants