88
99from zorak .utilities .cog_helpers ._embeds import embed_leaderboard
1010
11+
1112class Points (commands .Cog ):
1213 """
1314 Handles automatic points based on activity.
@@ -41,14 +42,14 @@ async def on_message_delete(self, message: discord.Message):
4142 mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
4243 await mod_log .send (f"1 Point removed from { message .author } for deleting a message." )
4344 self .bot .db_client .remove_points_from_user (message .author .id , 1 )
44-
45- # TODO: Fix the backup command.
46- # @commands.slash_command()
47- # @commands.has_any_role("Staff", "Owner", "Project Manager")
48- # async def backup_db(self, ctx):
49- # """Backup the MongoDB instance."""
50- # self.bot.db_client.backup_db()
51- # await ctx.respond("Database backed up.")
45+ #
46+ # # TODO: Fix the backup command.
47+ # # @commands.slash_command()
48+ # # @commands.has_any_role("Staff", "Owner", "Project Manager")
49+ # # async def backup_db(self, ctx):
50+ # # """Backup the MongoDB instance."""
51+ # # self.bot.db_client.backup_db()
52+ # # await ctx.respond("Database backed up.")
5253
5354 @commands .slash_command ()
5455 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
@@ -59,27 +60,29 @@ async def add_all_members_to_db(self, ctx):
5960
6061 @commands .slash_command ()
6162 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
62- async def add_points_to_user (self , ctx , mention : discord . Option [ str ] , points : discord . Option [ int ] ):
63+ async def add_points_to_user (self , ctx , mention , points ):
6364 """Add points to a user."""
6465 user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
65- self .bot .db_client .add_points_to_user (user .id , points )
66+ self .bot .db_client .add_points_to_user (user .id , int ( points ) )
6667 mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
67- await mod_log .send (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} added to { mention } by { ctx .author } ." )
68- await ctx .respond (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} added to { mention } ." )
68+ await mod_log .send (f"{ points } point{ ('s' , '' )[abs (int ( points ) ) == 1 ]} added to { mention } by { ctx .author } ." )
69+ await ctx .respond (f"{ points } point{ ('s' , '' )[abs (int ( points ) ) == 1 ]} added to { mention } ." )
6970
7071 @commands .slash_command ()
7172 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
72- async def add_points_to_all_users (self , ctx , points : discord . Option [ int ] ):
73+ async def add_points_to_all_users (self , ctx , points ):
7374 """Add points to all users."""
74- self .bot .db_client .add_points_to_all_users (points )
75+ self .bot .db_client .add_points_to_all_users (int ( points ) )
7576 mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
76- await mod_log .send (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} added to all users by { ctx .author } ." )
77- await ctx .respond (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} added to all users." )
77+ await mod_log .send (f"{ points } point{ ('s' , '' )[abs (int ( points ) ) == 1 ]} added to all users by { ctx .author } ." )
78+ await ctx .respond (f"{ points } point{ ('s' , '' )[abs (int ( points ) ) == 1 ]} added to all users." )
7879
7980 @commands .slash_command ()
8081 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
81- async def remove_points_from_user (self , ctx , mention : discord . Option [ str ] , points : discord . Option [ int ] ):
82+ async def remove_points_from_user (self , ctx , mention , points ):
8283 """Remove points from a user."""
84+ mention = str (mention )
85+ points = int (points )
8386 user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
8487 self .bot .db_client .remove_points_from_user (user .id , points )
8588 mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
@@ -88,17 +91,19 @@ async def remove_points_from_user(self, ctx, mention: discord.Option[str], point
8891
8992 @commands .slash_command ()
9093 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
91- async def remove_points_from_all_users (self , ctx , points : discord . Option [ int ] ):
94+ async def remove_points_from_all_users (self , ctx , points ):
9295 """Remove points from all users."""
96+ points = int (points )
9397 self .bot .db_client .remove_points_from_all_users (points )
9498 mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
9599 await mod_log .send (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from all users by { ctx .author } ." )
96100 await ctx .respond (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from all users." )
97101
98102 @commands .slash_command ()
99103 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
100- async def reset_points_for_user (self , ctx , mention : discord . Option [ str ] ):
104+ async def reset_points_for_user (self , ctx , mention ):
101105 """Reset points for a user."""
106+ mention = str (mention )
102107 user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
103108 self .bot .db_client .set_user_points (user .id , 0 )
104109 mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
@@ -116,8 +121,9 @@ async def reset_points_for_all_users(self, ctx):
116121
117122 @commands .slash_command ()
118123 @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
119- async def get_points_for_user (self , ctx , mention : discord . Option [ str ] ):
124+ async def get_points_for_user (self , ctx , mention ):
120125 """Get points for a user."""
126+ mention = str (mention )
121127 user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
122128 points = self .bot .db_client .get_user_points (user .id )
123129 await ctx .respond (f"{ mention } has { points } point{ ('s' , '' )[abs (points ) == 1 ]} ." )
@@ -142,11 +148,11 @@ def is_staff(member_obj):
142148 if not is_staff (member ):
143149 top10_no_staff .append ((member , person ['Points' ]))
144150
145- embed = embed_leaderboard (top10_no_staff , self .bot .server_settings .server_info ['name' ], self .bot .server_settings .server_info ['logo' ])
151+ embed = embed_leaderboard (top10_no_staff , self .bot .server_settings .server_info ['name' ],
152+ self .bot .server_settings .server_info ['logo' ])
146153 await ctx .respond (embed = embed )
147154
148155
149-
150156def setup (bot ):
151157 """required"""
152158 bot .add_cog (Points (bot ))
0 commit comments