Leaderboard command not working . No error No response
infinotiver opened this issue · 30 comments
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
Well, it worked for me ( i didn't try now ). Try seeing json file ? How it is saving
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
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.
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 ?
", 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
The main problem is with member.id thing
Check json file? Btw i suggest you create bot from scratch and use these as a idea of how to make :)
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
@AyushSehrawat btw how do I add a command of showing detailed information about the item
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
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.
For detailed info abt item, add another key in dictionary ?
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
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
I will figure out
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
@prakarsh17 You can check new readme for how to get mongodb instead of json :)
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?
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?
?
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
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 :)
Leaderbord and extra commands soon :)
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
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
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
oh so you are online , are u on discord btw
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
ok pls tell your discord username
Mini#5183
@prakarsh17 https://discord.gg/gQ9rcuNK75 : For discord server