@@ -16,33 +16,28 @@ class Points(commands.Cog):
16
16
17
17
def __init__ (self , bot ):
18
18
if not hasattr (bot , "db_client" ):
19
- print ('fuck' )
20
19
raise Exception ("Database client not found." )
21
20
self .bot = bot
22
21
23
22
@commands .Cog .listener ()
24
23
async def on_member_join (self , member : discord .Member ): # pylint: disable=E1101
25
- print ('On_member_join' )
26
24
"""When a member joins, add them to the DB."""
27
25
self .bot .db_client .add_user_to_table (member )
28
26
29
27
@commands .Cog .listener ()
30
28
async def on_member_remove (self , member : discord .Member ): # pylint: disable=E1101
31
- print ('On_member_rem' )
32
29
"""When a member leaves, remove them from the DB."""
33
30
self .bot .db_client .remove_user_from_table (member )
34
31
35
32
@commands .Cog .listener ()
36
33
async def on_message (self , message : discord .Message ):
37
- print ('On_mess' )
38
34
"""When a member sends a message, give them 1 point."""
39
35
if message .author .bot :
40
36
return
41
37
self .bot .db_client .add_points_to_user (message .author .id , 1 )
42
38
43
39
@commands .Cog .listener ()
44
40
async def on_message_delete (self , message : discord .Message ):
45
- print ('On_del' )
46
41
"""When a member deletes a message, remove a point."""
47
42
mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
48
43
await mod_log .send (f"1 Point removed from { message .author } for deleting a message." )
@@ -59,86 +54,82 @@ async def on_message_delete(self, message: discord.Message):
59
54
@commands .slash_command ()
60
55
@commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
61
56
async def add_all_members_to_db (self , ctx ):
62
- print ('add all' )
63
57
"""Add all members to the database."""
64
58
self .bot .db_client .create_table_from_members (ctx .guild .members )
65
59
await ctx .respond ("All members added to database." )
66
60
67
61
@commands .slash_command ()
68
62
@commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
69
63
async def add_points_to_user (self , ctx , mention , points ):
70
- print ('add to user' )
71
64
"""Add points to a user."""
72
65
user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
73
66
self .bot .db_client .add_points_to_user (user .id , int (points ))
74
67
mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
75
68
await mod_log .send (f"{ points } point{ ('s' , '' )[abs (int (points )) == 1 ]} added to { mention } by { ctx .author } ." )
76
69
await ctx .respond (f"{ points } point{ ('s' , '' )[abs (int (points )) == 1 ]} added to { mention } ." )
77
70
78
- # @commands.slash_command()
79
- # @commands.has_any_role("Staff", "Owner", "Project Manager")
80
- # async def add_points_to_all_users(self, ctx, points: discord.Option[int] ):
81
- # print('add to all users')
82
- # """Add points to all users."""
83
- # self.bot.db_client.add_points_to_all_users(points )
84
- # mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"] )
85
- # await mod_log.send (f"{points} point{('s', '')[abs(points) == 1]} added to all users by {ctx.author} .")
86
- # await ctx.respond(f"{points} point{('s', '')[abs(points) == 1]} added to all users.")
87
- #
88
- # @commands.slash_command( )
89
- # @commands.has_any_role("Staff", "Owner", "Project Manager")
90
- # async def remove_points_from_user(self, ctx, mention: discord.Option[str], points: discord.Option[int]):
91
- # print('remove user' )
92
- # """Remove points from a user."""
93
- # user = self.bot.get_user(int(mention.split("@")[1].split(">")[0]))
94
- # self.bot.db_client.remove_points_from_user(user.id, points)
95
- # mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
96
- # await mod_log.send(f"{points} point{('s', '')[abs(points) == 1]} removed from {mention} by {ctx.author}.")
97
- # await ctx.respond(f"{points} point{('s', '')[abs(points) == 1]} removed from {mention}.")
98
- #
99
- # @commands.slash_command()
100
- # @commands.has_any_role("Staff", "Owner", "Project Manager")
101
- # async def remove_points_from_all_users(self, ctx, points: discord.Option[int] ):
102
- # print('remove all users')
103
- # """Remove points from all users."""
104
- # self.bot.db_client.remove_points_from_all_users(points)
105
- # mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
106
- # await mod_log.send(f"{points} point{('s', '')[abs(points) == 1]} removed from all users by {ctx.author}.")
107
- # await ctx.respond(f"{points} point{('s', '')[abs(points) == 1]} removed from all users.")
108
- #
109
- # @commands.slash_command()
110
- # @commands.has_any_role("Staff", "Owner", "Project Manager")
111
- # async def reset_points_for_user(self, ctx, mention: discord.Option[str] ):
112
- # print('reset')
113
- # """Reset points for a user."""
114
- # user = self.bot.get_user(int(mention.split("@")[1].split(">")[0]))
115
- # self.bot.db_client.set_user_points(user.id, 0)
116
- # mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
117
- # await mod_log.send(f"Points reset for {mention} by {ctx.author}.")
118
- # await ctx.respond(f"Points reset for {mention}.")
71
+ @commands .slash_command ()
72
+ @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
73
+ async def add_points_to_all_users (self , ctx , points ):
74
+ """Add points to all users."""
75
+ self . bot . db_client . add_points_to_all_users ( int ( points ))
76
+ mod_log = await self .bot .fetch_channel ( self . bot . server_settings . log_channel [ "mod_log" ] )
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." )
79
+
80
+ @ commands . slash_command ()
81
+ @commands .has_any_role ( "Staff" , "Owner" , "Project Manager" )
82
+ async def remove_points_from_user ( self , ctx , mention , points ):
83
+ """Remove points from a user."""
84
+ mention = str ( mention )
85
+ points = int ( points )
86
+ user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
87
+ self .bot .db_client .remove_points_from_user (user .id , points )
88
+ mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
89
+ await mod_log .send (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from { mention } by { ctx .author } ." )
90
+ await ctx .respond (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from { mention } ." )
91
+
92
+ @commands .slash_command ()
93
+ @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
94
+ async def remove_points_from_all_users (self , ctx , points ):
95
+ """Remove points from all users."""
96
+ points = int ( points )
97
+ self .bot .db_client .remove_points_from_all_users (points )
98
+ mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
99
+ await mod_log .send (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from all users by { ctx .author } ." )
100
+ await ctx .respond (f"{ points } point{ ('s' , '' )[abs (points ) == 1 ]} removed from all users." )
101
+
102
+ @commands .slash_command ()
103
+ @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
104
+ async def reset_points_for_user (self , ctx , mention ):
105
+ """Reset points for a user."""
106
+ mention = str ( mention )
107
+ user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
108
+ self .bot .db_client .set_user_points (user .id , 0 )
109
+ mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
110
+ await mod_log .send (f"Points reset for { mention } by { ctx .author } ." )
111
+ await ctx .respond (f"Points reset for { mention } ." )
119
112
120
113
@commands .slash_command ()
121
114
@commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
122
115
async def reset_points_for_all_users (self , ctx ):
123
- print ('reset all' )
124
116
"""Reset points for all users."""
125
117
self .bot .db_client .set_all_user_points (0 )
126
118
mod_log = await self .bot .fetch_channel (self .bot .server_settings .log_channel ["mod_log" ])
127
119
await mod_log .send (f"Points reset for all users by { ctx .author } ." )
128
120
await ctx .respond ("Points reset for all users." )
129
121
130
- # @commands.slash_command()
131
- # @commands.has_any_role("Staff", "Owner", "Project Manager")
132
- # async def get_points_for_user(self, ctx, mention: discord.Option[str] ):
133
- # print('get points')
134
- # """Get points for a user."""
135
- # user = self.bot.get_user(int(mention.split("@")[1].split(">")[0]))
136
- # points = self.bot.db_client.get_user_points(user.id)
137
- # await ctx.respond(f"{mention} has {points} point{('s', '')[abs(points) == 1]}.")
122
+ @commands .slash_command ()
123
+ @commands .has_any_role ("Staff" , "Owner" , "Project Manager" )
124
+ async def get_points_for_user (self , ctx , mention ):
125
+ """Get points for a user."""
126
+ mention = str ( mention )
127
+ user = self .bot .get_user (int (mention .split ("@" )[1 ].split (">" )[0 ]))
128
+ points = self .bot .db_client .get_user_points (user .id )
129
+ await ctx .respond (f"{ mention } has { points } point{ ('s' , '' )[abs (points ) == 1 ]} ." )
138
130
139
131
@commands .slash_command ()
140
132
async def leaderboard (self , ctx ):
141
- print ('leader' )
142
133
"""Get your points."""
143
134
144
135
def is_staff (member_obj ):
@@ -161,8 +152,6 @@ def is_staff(member_obj):
161
152
self .bot .server_settings .server_info ['logo' ])
162
153
await ctx .respond (embed = embed )
163
154
164
- print ('thru all defs' )
165
-
166
155
167
156
def setup (bot ):
168
157
"""required"""
0 commit comments