Skip to content

Commit 8591b73

Browse files
authored
Merge pull request #329 from rHomelab/refactor/report_bool_conversion
2 parents 512a901 + 25166a5 commit 8591b73

1 file changed

Lines changed: 3 additions & 15 deletions

File tree

report/report.py

Lines changed: 3 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -59,19 +59,14 @@ async def reports_logchannel(self, ctx: commands.GuildContext, channel: discord.
5959

6060
@_reports.command("confirmation")
6161
@commands.guild_only()
62-
async def reports_confirm(self, ctx: commands.GuildContext, option: str):
62+
async def reports_confirm(self, ctx: commands.GuildContext, option: bool):
6363
"""Whether a confirmation should be sent to reporters.
6464
6565
Example:
6666
- `[p]reports confirm <True|False>`
6767
"""
68-
try:
69-
confirmation = strtobool(option)
70-
except ValueError:
71-
await ctx.send("❌ Invalid option. Use: `[p]reports confirm <True|False>`")
72-
return
73-
await self.config.guild(ctx.guild).confirmations.set(confirmation)
74-
await ctx.send(f"✅ Report confirmations {'enabled' if confirmation else 'disabled'}")
68+
await self.config.guild(ctx.guild).confirmations.set(option)
69+
await ctx.send(f"✅ Report confirmations {'enabled' if option else 'disabled'}")
7570

7671
@_reports.command("status")
7772
@commands.guild_only()
@@ -247,10 +242,3 @@ def make_reporter_reply(
247242
.add_field(name="Report Origin", value=channel.mention)
248243
.add_field(name="Report Content", value=escape(report_body or "<no message>"))
249244
)
250-
251-
252-
def strtobool(value: str) -> bool:
253-
value = value.lower()
254-
if value in ("y", "yes", "on", "1", "true", "t"):
255-
return True
256-
return False

0 commit comments

Comments
 (0)