Skip to content

Commit 3e8e188

Browse files
committed
removed typing from the db cog
Shitty, but maybe we will move over to cockroach soon, so whatever.
1 parent 2df8b4b commit 3e8e188

File tree

2 files changed

+50
-61
lines changed

2 files changed

+50
-61
lines changed

.env.example

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,4 @@ ENVIRONMENT=dev #Lets us use just the one compose for both dev and prod
88

99
# Logging
1010
LOGGING_LEVEL=20
11-
STREAM_LOGS=FALSE
11+
STREAM_LOGS=FALSE

src/zorak/cogs/utility/points.py

Lines changed: 49 additions & 60 deletions
Original file line numberDiff line numberDiff line change
@@ -16,33 +16,28 @@ class Points(commands.Cog):
1616

1717
def __init__(self, bot):
1818
if not hasattr(bot, "db_client"):
19-
print('fuck')
2019
raise Exception("Database client not found.")
2120
self.bot = bot
2221

2322
@commands.Cog.listener()
2423
async def on_member_join(self, member: discord.Member): # pylint: disable=E1101
25-
print('On_member_join')
2624
"""When a member joins, add them to the DB."""
2725
self.bot.db_client.add_user_to_table(member)
2826

2927
@commands.Cog.listener()
3028
async def on_member_remove(self, member: discord.Member): # pylint: disable=E1101
31-
print('On_member_rem')
3229
"""When a member leaves, remove them from the DB."""
3330
self.bot.db_client.remove_user_from_table(member)
3431

3532
@commands.Cog.listener()
3633
async def on_message(self, message: discord.Message):
37-
print('On_mess')
3834
"""When a member sends a message, give them 1 point."""
3935
if message.author.bot:
4036
return
4137
self.bot.db_client.add_points_to_user(message.author.id, 1)
4238

4339
@commands.Cog.listener()
4440
async def on_message_delete(self, message: discord.Message):
45-
print('On_del')
4641
"""When a member deletes a message, remove a point."""
4742
mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
4843
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):
5954
@commands.slash_command()
6055
@commands.has_any_role("Staff", "Owner", "Project Manager")
6156
async def add_all_members_to_db(self, ctx):
62-
print('add all')
6357
"""Add all members to the database."""
6458
self.bot.db_client.create_table_from_members(ctx.guild.members)
6559
await ctx.respond("All members added to database.")
6660

6761
@commands.slash_command()
6862
@commands.has_any_role("Staff", "Owner", "Project Manager")
6963
async def add_points_to_user(self, ctx, mention, points):
70-
print('add to user')
7164
"""Add points to a user."""
7265
user = self.bot.get_user(int(mention.split("@")[1].split(">")[0]))
7366
self.bot.db_client.add_points_to_user(user.id, int(points))
7467
mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
7568
await mod_log.send(f"{points} point{('s', '')[abs(int(points)) == 1]} added to {mention} by {ctx.author}.")
7669
await ctx.respond(f"{points} point{('s', '')[abs(int(points)) == 1]} added to {mention}.")
7770

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}.")
119112

120113
@commands.slash_command()
121114
@commands.has_any_role("Staff", "Owner", "Project Manager")
122115
async def reset_points_for_all_users(self, ctx):
123-
print('reset all')
124116
"""Reset points for all users."""
125117
self.bot.db_client.set_all_user_points(0)
126118
mod_log = await self.bot.fetch_channel(self.bot.server_settings.log_channel["mod_log"])
127119
await mod_log.send(f"Points reset for all users by {ctx.author}.")
128120
await ctx.respond("Points reset for all users.")
129121

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]}.")
138130

139131
@commands.slash_command()
140132
async def leaderboard(self, ctx):
141-
print('leader')
142133
"""Get your points."""
143134

144135
def is_staff(member_obj):
@@ -161,8 +152,6 @@ def is_staff(member_obj):
161152
self.bot.server_settings.server_info['logo'])
162153
await ctx.respond(embed=embed)
163154

164-
print('thru all defs')
165-
166155

167156
def setup(bot):
168157
"""required"""

0 commit comments

Comments
 (0)