Skip to content

Commit a3ff70d

Browse files
committed
[Strikes] Fix permissions for !allstrikes and !strikecounts
These commands were previously unrestricted, but they now require the caller to have the Mod role (see `!set roles`), or the "Kick Members" permission.
1 parent 2accb26 commit a3ff70d

File tree

1 file changed

+15
-7
lines changed

1 file changed

+15
-7
lines changed

strikes/strikes.py

Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -43,7 +43,7 @@ def __init__(self, bot: Red, db: Union[str, bytes, os.PathLike, None] = None):
4343
super().__init__()
4444

4545
async def initialize(self):
46-
# Casetype registration
46+
# Case-type registration
4747
with contextlib.suppress(RuntimeError):
4848
await modlog.register_casetype(**_CASETYPE)
4949

@@ -144,7 +144,7 @@ async def create_case(
144144
Parameters
145145
----------
146146
member : discord.Member
147-
The member who was striked.
147+
The member who has received a strike.
148148
timestamp : datetime.datetime
149149
The timestamp for the strike.
150150
reason : str
@@ -236,6 +236,8 @@ async def strikes(self, ctx: commands.Context, *, member: discord.Member):
236236
)
237237
)
238238

239+
@checks.mod_or_permissions(kick_members=True)
240+
@commands.guild_only()
239241
@commands.command()
240242
async def allstrikes(self, ctx: commands.Context, num_days: int = 30):
241243
"""Show all recent individual strikes.
@@ -248,7 +250,7 @@ async def allstrikes(self, ctx: commands.Context, num_days: int = 30):
248250
if num_days < 0:
249251
await ctx.send(
250252
_(
251-
"You must specify a number of days of at least 0 to retreive "
253+
"You must specify a number of days of at least 0 to retrieve "
252254
"strikes from."
253255
)
254256
)
@@ -273,7 +275,6 @@ async def allstrikes(self, ctx: commands.Context, num_days: int = 30):
273275
table = self._create_table(cursor, ctx.guild, show_id=False)
274276

275277
if table:
276-
print(len(table))
277278
pages = pagify(table, shorten_by=25)
278279
if num_days:
279280
await ctx.send(
@@ -296,6 +297,8 @@ async def allstrikes(self, ctx: commands.Context, num_days: int = 30):
296297
else:
297298
await ctx.send(_("No users in this server have ever received strikes!"))
298299

300+
@checks.mod_or_permissions(kick_members=True)
301+
@commands.guild_only()
299302
@commands.command()
300303
async def strikecounts(
301304
self,
@@ -324,15 +327,15 @@ async def strikecounts(
324327
if num_days < 0:
325328
await ctx.send(
326329
_(
327-
"You must specify a number of days of at least 0 to retreive "
330+
"You must specify a number of days of at least 0 to retrieve "
328331
"strikes from."
329332
)
330333
)
331334
return
332335
if limit < 1:
333336
await ctx.send(
334337
_(
335-
"You must specify a number of members of at least 1 to retreive "
338+
"You must specify a number of members of at least 1 to retrieve "
336339
"strikes for."
337340
)
338341
)
@@ -358,7 +361,12 @@ async def strikecounts(
358361
with self._db_connect() as conn:
359362
cursor = conn.execute(
360363
f"""
361-
SELECT max(id) as most_recent_id, user, count(user) as count FROM strikes
364+
SELECT
365+
max(id) as most_recent_id,
366+
user,
367+
count(user) as count
368+
FROM
369+
strikes
362370
WHERE
363371
guild = ?
364372
AND id > ?

0 commit comments

Comments
 (0)