[Warnings] Improve consistency in [p]warningset's commands (#4409)

* Be consistent with bool setters in warnings cog

* black
This commit is contained in:
Dav 2020-09-20 00:16:42 +02:00 committed by GitHub
parent 343efba4d5
commit 980b5fa1c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -126,12 +126,10 @@ class Warnings(commands.Cog):
@warningset.command()
@commands.guild_only()
async def toggledm(self, ctx: commands.Context):
"""Toggle whether warnings should be sent to users in DMs."""
guild = ctx.guild
toggle = not await self.config.guild(guild).toggle_dm()
await self.config.guild(guild).toggle_dm.set(toggle)
if toggle:
async def senddm(self, ctx: commands.Context, true_or_false: bool):
"""Set whether warnings should be sent to users in DMs."""
await self.config.guild(ctx.guild).toggle_dm.set(true_or_false)
if true_or_false:
await ctx.send(_("I will now try to send warnings to users DMs."))
else:
await ctx.send(_("Warnings will no longer be sent to users DMs."))
@ -173,15 +171,13 @@ class Warnings(commands.Cog):
@warningset.command()
@commands.guild_only()
async def togglechannel(self, ctx: commands.Context):
async def usewarnchannel(self, ctx: commands.Context, true_or_false: bool):
"""
Toggle if warnings should be sent to a channel set with `[p]warningset warnchannel`.
Set if warnings should be sent to a channel set with `[p]warningset warnchannel`.
"""
guild = ctx.guild
toggle = await self.config.guild(guild).toggle_channel()
await self.config.guild(guild).toggle_channel.set(not toggle)
channel = self.bot.get_channel(await self.config.guild(guild).warn_channel())
if not toggle:
await self.config.guild(ctx.guild).toggle_channel.set(true_or_false)
channel = self.bot.get_channel(await self.config.guild(ctx.guild).warn_channel())
if true_or_false:
if channel:
await ctx.send(
_("Warnings will now be sent to {channel}.").format(channel=channel.mention)