8
8
9
9
from zorak .utilities .cog_helpers ._embeds import embed_leaderboard
10
10
11
+
11
12
class Points (commands .Cog ):
12
13
"""
13
14
Handles automatic points based on activity.
@@ -41,14 +42,14 @@ async def on_message_delete(self, message: discord.Message):
41
42
mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
42
43
await mod_log .send (f"1 Point removed from { message .author } for deleting a message." )
43
44
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.")
52
53
53
54
@commands .slash_command ()
54
55
@commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
@@ -59,27 +60,29 @@ async def add_all_members_to_db(self, ctx):
59
60
60
61
@commands .slash_command ()
61
62
@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 ):
63
64
"""Add points to a user."""
64
65
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 ) )
66
67
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 } ." )
69
70
70
71
@commands .slash_command ()
71
72
@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 ):
73
74
"""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 ) )
75
76
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." )
78
79
79
80
@commands .slash_command ()
80
81
@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 ):
82
83
"""Remove points from a user."""
84
+ mention = str (mention )
85
+ points = int (points )
83
86
user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
84
87
self .bot .db_client .remove_points_from_user (user .id , points )
85
88
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
88
91
89
92
@commands .slash_command ()
90
93
@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 ):
92
95
"""Remove points from all users."""
96
+ points = int (points )
93
97
self .bot .db_client .remove_points_from_all_users (points )
94
98
mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
95
99
await mod_log .send (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from all users by { ctx .author } ." )
96
100
await ctx .respond (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from all users." )
97
101
98
102
@commands .slash_command ()
99
103
@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 ):
101
105
"""Reset points for a user."""
106
+ mention = str (mention )
102
107
user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
103
108
self .bot .db_client .set_user_points (user .id , 0 )
104
109
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):
116
121
117
122
@commands .slash_command ()
118
123
@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 ):
120
125
"""Get points for a user."""
126
+ mention = str (mention )
121
127
user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
122
128
points = self .bot .db_client .get_user_points (user .id )
123
129
await ctx .respond (f"{ mention } has { points } point{ ('s' , '' )[abs (points ) == 1 ]} ." )
@@ -142,11 +148,11 @@ def is_staff(member_obj):
142
148
if not is_staff (member ):
143
149
top10_no_staff .append ((member , person ['Points' ]))
144
150
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' ])
146
153
await ctx .respond (embed = embed )
147
154
148
155
149
-
150
156
def setup (bot ):
151
157
"""required"""
152
158
bot .add_cog (Points (bot ))
0 commit comments