Skip to content

Commit fdf877c

Browse files
TsunderarislimeInjabie3
authored andcommitted
[Gatekeep] Adjust string formatting in logs and messages
1 parent 9d5a78b commit fdf877c

File tree

1 file changed

+18
-18
lines changed

1 file changed

+18
-18
lines changed

gatekeep/gatekeep.py

Lines changed: 18 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -93,7 +93,7 @@ async def setChannel(self, ctx: Context, channel: discord.TextChannel = None):
9393
if channel:
9494
await self.config.guild(ctx.guild).get_attr(KEY_LOG_CHANNEL).set(channel.id)
9595
self.logger.info(
96-
"%s#%s (%s) set the gatekeep logging channel to %s",
96+
"%s#%s (%s) set the gatekeep logging channel to %s.",
9797
ctx.author.name,
9898
ctx.author.discriminator,
9999
ctx.author.id,
@@ -124,14 +124,14 @@ async def setThreshold(self, ctx: Context, threshold: int):
124124
if threshold > 0:
125125
await self.config.guild(ctx.guild).get_attr(KEY_THRESHOLD).set(threshold)
126126
self.logger.info(
127-
"%s#%s (%s) set the threshold to %s",
127+
"%s#%s (%s) set the threshold to %d.",
128128
ctx.author.name,
129129
ctx.author.discriminator,
130130
ctx.author.id,
131-
str(threshold),
131+
threshold,
132132
)
133133
await ctx.send(
134-
f":white_check_mark: **Gatekeep - Threshold**: The threshold has been updated to **{threshold}**"
134+
f":white_check_mark: **Gatekeep - Threshold**: The threshold has been updated to **{threshold}**."
135135
)
136136
else:
137137
await ctx.send("The value for the threshold should be greater than 0!")
@@ -152,15 +152,15 @@ async def setAttachmentWeight(self, ctx: Context, weight: int):
152152
if weight >= 0:
153153
await self.config.guild(ctx.guild).get_attr(KEY_ATTACHMENT_WEIGHT).set(weight)
154154
self.logger.info(
155-
"%s#%s (%s) set the attachment weight to %s",
155+
"%s#%s (%s) set the attachment weight to %d.",
156156
ctx.author.name,
157157
ctx.author.discriminator,
158158
ctx.author.id,
159-
str(weight),
159+
weight,
160160
)
161161
await ctx.send(
162162
f":white_check_mark: **Gatekeep - Attachment Weight**: "
163-
f"The attachment weight has been updated to **{weight}**"
163+
f"The attachment weight has been updated to **{weight}**."
164164
)
165165
else:
166166
await ctx.send("The value for the threshold should be greater than or equal to 0!")
@@ -180,14 +180,14 @@ async def setDays(self, ctx: Context, days: int):
180180
if days > 0:
181181
await self.config.guild(ctx.guild).get_attr(KEY_NEW_USER_DAYS).set(days)
182182
self.logger.info(
183-
"%s#%s (%s) set the number of days to %s",
183+
"%s#%s (%s) set the number of days to %d.",
184184
ctx.author.name,
185185
ctx.author.discriminator,
186186
ctx.author.id,
187-
str(days),
187+
days,
188188
)
189189
await ctx.send(
190-
f":white_check_mark: **Gatekeep - Days**: The number of days has been updated to **{days}**"
190+
f":white_check_mark: **Gatekeep - Days**: The number of days has been updated to **{days}**."
191191
)
192192
else:
193193
await ctx.send("The value for the days should be greater than 0!")
@@ -306,12 +306,12 @@ async def addWord(self, ctx: Context, word: str, weight: int):
306306
await ctx.send(f"Added the word `{w}` with a weight of **{weight}**.")
307307

308308
self.logger.info(
309-
"%s#%s (%s) added/updated %s with weight %s.",
309+
"%s#%s (%s) added/updated %s with weight %d.",
310310
ctx.author.name,
311311
ctx.author.discriminator,
312312
ctx.author.id,
313313
w,
314-
str(weight),
314+
weight,
315315
)
316316

317317
else:
@@ -622,9 +622,9 @@ def check(msg: discord.Message):
622622

623623
async def watchlistLoop(self):
624624
"""Daily update loop to keep the watchlist small."""
625-
self.logger.info("Waiting for bot to be ready")
625+
self.logger.info("Waiting for bot to be ready...")
626626
await self.bot.wait_until_red_ready()
627-
self.logger.info("Bot is ready")
627+
self.logger.info("Bot is ready.")
628628
while self == self.bot.get_cog("Gatekeep"):
629629
if self.lastChecked.day != datetime.now().day:
630630
self.lastChecked = datetime.now()
@@ -662,7 +662,7 @@ async def checkWatchlist(self):
662662
"Member with id (%s) removed from the watch list. (Not in server)", id
663663
)
664664

665-
self.logger.info("Refreshed the watch list for %s", guild.name)
665+
self.logger.info("Refreshed the watch list for %s.", guild.name)
666666

667667
# The async function that is triggered on new member join.
668668
@commands.Cog.listener()
@@ -755,13 +755,13 @@ async def on_message(self, message: discord.Message):
755755
)
756756

757757
self.logger.info(
758-
"%s#%s (%s) was banned from %s for spam. Message score was %s, which exceed threshold of %s.",
758+
"%s#%s (%s) was banned from %s for spam. Message score was %d, which exceed threshold of %d.",
759759
author.name,
760760
author.discriminator,
761761
author.id,
762762
message.guild.name,
763-
str(score),
764-
str(th),
763+
score,
764+
th,
765765
)
766766

767767
banCount = await self.config.guild(message.guild).get_attr(KEY_BAN_COUNT)()

0 commit comments

Comments
 (0)