Added level to message_xp.py !stats
This commit is contained in:
parent
907c23176c
commit
697a7df551
1 changed files with 109 additions and 1 deletions
|
|
@ -16,7 +16,8 @@ class MessageXP(BotBaseCog):
|
||||||
try:
|
try:
|
||||||
xp_data = read_xp_file(self)
|
xp_data = read_xp_file(self)
|
||||||
if author_id in xp_data:
|
if author_id in xp_data:
|
||||||
await ctx.send(f"You have {xp_data[author_id]} XP")
|
level = get_level_from_xp(xp_data[author_id])
|
||||||
|
await ctx.send(f"You are level {level} with {xp_data[author_id]} XP")
|
||||||
else:
|
else:
|
||||||
await ctx.send("You have 0 XP")
|
await ctx.send("You have 0 XP")
|
||||||
except:
|
except:
|
||||||
|
|
@ -55,6 +56,113 @@ def read_xp_file(self):
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
self.logger.error(f"No XP file found. Returning empty json object: {e}")
|
self.logger.error(f"No XP file found. Returning empty json object: {e}")
|
||||||
return {}
|
return {}
|
||||||
|
|
||||||
|
def get_level_from_xp(xp):
|
||||||
|
xp_dict = {
|
||||||
|
1: 0,
|
||||||
|
2: 83,
|
||||||
|
3: 174,
|
||||||
|
4: 276,
|
||||||
|
5: 388,
|
||||||
|
6: 512,
|
||||||
|
7: 650,
|
||||||
|
8: 801,
|
||||||
|
9: 801,
|
||||||
|
10: 1_154,
|
||||||
|
11: 1_358,
|
||||||
|
12: 1_584,
|
||||||
|
13: 1_833,
|
||||||
|
14: 2_107,
|
||||||
|
15: 2_411,
|
||||||
|
16: 2_746,
|
||||||
|
17: 3_115,
|
||||||
|
18: 3_523,
|
||||||
|
19: 3_973,
|
||||||
|
20: 4_470,
|
||||||
|
21: 5_018,
|
||||||
|
22: 5_624,
|
||||||
|
23: 6_291,
|
||||||
|
24: 7_028,
|
||||||
|
25: 7_842,
|
||||||
|
26: 8_740,
|
||||||
|
27: 9_730,
|
||||||
|
28: 10_824,
|
||||||
|
29: 12_031,
|
||||||
|
30: 13_363,
|
||||||
|
31: 14_833,
|
||||||
|
32: 16_456,
|
||||||
|
33: 18_247,
|
||||||
|
34: 20_224,
|
||||||
|
35: 22_406,
|
||||||
|
36: 24_815,
|
||||||
|
37: 27_473,
|
||||||
|
38: 30_408,
|
||||||
|
39: 33_648,
|
||||||
|
40: 37_224,
|
||||||
|
41: 41_171,
|
||||||
|
42: 45_529,
|
||||||
|
43: 50_339,
|
||||||
|
44: 55_649,
|
||||||
|
45: 61_512,
|
||||||
|
46: 67_983,
|
||||||
|
47: 75_127,
|
||||||
|
48: 83_014,
|
||||||
|
49: 91_721,
|
||||||
|
50: 101_333,
|
||||||
|
51: 111_945,
|
||||||
|
52: 123_660,
|
||||||
|
53: 136_594,
|
||||||
|
54: 150_872,
|
||||||
|
55: 166_636,
|
||||||
|
56: 184_040,
|
||||||
|
57: 203_254,
|
||||||
|
58: 224_466,
|
||||||
|
59: 247_886,
|
||||||
|
60: 273_742,
|
||||||
|
61: 302_288,
|
||||||
|
62: 333_804,
|
||||||
|
63: 368_599,
|
||||||
|
64: 407_015,
|
||||||
|
65: 449_428,
|
||||||
|
66: 496_254,
|
||||||
|
67: 547_953,
|
||||||
|
68: 605_032,
|
||||||
|
69: 668_051,
|
||||||
|
70: 737_627,
|
||||||
|
71: 814_445,
|
||||||
|
72: 899_257,
|
||||||
|
73: 992_895,
|
||||||
|
74: 1_096_278,
|
||||||
|
75: 1_210_421,
|
||||||
|
76: 1_336_443,
|
||||||
|
77: 1_475_581,
|
||||||
|
78: 1_629_200,
|
||||||
|
79: 1_798_808,
|
||||||
|
80: 1_986_068,
|
||||||
|
81: 2_192_818,
|
||||||
|
82: 2_421_087,
|
||||||
|
83: 2_673_114,
|
||||||
|
84: 2_951_373,
|
||||||
|
85: 3_258_594,
|
||||||
|
86: 3_597_792,
|
||||||
|
87: 3_972_294,
|
||||||
|
88: 4_385_776,
|
||||||
|
89: 4_842_295,
|
||||||
|
90: 5_346_332,
|
||||||
|
91: 5_902_831,
|
||||||
|
92: 6_517_253,
|
||||||
|
93: 7_195_629,
|
||||||
|
94: 7_944_614,
|
||||||
|
95: 8_771_558,
|
||||||
|
96: 9_684_577,
|
||||||
|
97: 10_692_629,
|
||||||
|
98: 11_805_606,
|
||||||
|
99: 13_034_431
|
||||||
|
}
|
||||||
|
for level, xp_threshold in xp_dict.items():
|
||||||
|
if xp < xp_threshold:
|
||||||
|
return level - 1
|
||||||
|
return 99
|
||||||
|
|
||||||
|
|
||||||
async def setup(bot):
|
async def setup(bot):
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue