Replace all custom booleans with standard booleans

This commit is contained in:
Zeva Rose 2022-03-23 09:55:51 -06:00
parent be6d88449e
commit 75b850e734
5 changed files with 16 additions and 40 deletions

View file

@ -302,13 +302,13 @@ class BanCog(ModcaseCog):
@slash_option(
name="active",
description="Active bans",
opt_type=OptionTypes.INTEGER,
opt_type=OptionTypes.BOOLEAN,
required=False,
choices=[SlashCommandChoice(name="Yes", value=1), SlashCommandChoice(name="No", value=0)],
)
@check(admin_or_permissions(Permissions.BAN_MEMBERS))
async def _bans_list(self, ctx: InteractionContext, btype: int = 0, active: int = 1) -> None:
active = bool(active)
async def _bans_list(
self, ctx: InteractionContext, btype: int = 0, active: bool = True
) -> None:
types = [0, "perm", "temp", "soft"]
search = {"guild": ctx.guild.id}
if active:

View file

@ -6,7 +6,6 @@ from dis_snek.models.discord.embed import EmbedField
from dis_snek.models.discord.user import User
from dis_snek.models.snek.application_commands import (
OptionTypes,
SlashCommandChoice,
slash_command,
slash_option,
)
@ -66,17 +65,11 @@ class WarningCog(ModcaseCog):
@slash_option(
name="active",
description="View active only",
opt_type=OptionTypes.INTEGER,
opt_type=OptionTypes.BOOLEAN,
required=False,
choices=[
SlashCommandChoice(name="Yes", value=1),
SlashCommandChoice(name="No", value=0),
],
)
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _warnings(self, ctx: InteractionContext, user: User, active: bool = 1) -> None:
active = bool(active)
async def _warnings(self, ctx: InteractionContext, user: User, active: bool = True) -> None:
warnings = (
await Warning.find(
user=user.id,

View file

@ -13,7 +13,6 @@ from dis_snek.models.discord.embed import Embed, EmbedField
from dis_snek.models.discord.modal import InputText, Modal, TextStyles
from dis_snek.models.snek.application_commands import (
OptionTypes,
SlashCommandChoice,
slash_command,
slash_option,
)
@ -37,19 +36,14 @@ class RemindmeCog(Scale):
@slash_option(
name="private",
description="Send as DM?",
opt_type=OptionTypes.STRING,
opt_type=OptionTypes.BOOLEAN,
required=False,
choices=[
SlashCommandChoice(name="Yes", value="y"),
SlashCommandChoice(name="No", value="n"),
],
)
async def _remindme(
self,
ctx: InteractionContext,
private: str = "n",
private: bool = False,
) -> None:
private = private == "y"
modal = Modal(
title="Set your reminder!",
components=[

View file

@ -150,16 +150,16 @@ class SettingsCog(Scale):
create_option(
name="active",
description="Active?",
opt_type=4,
opt_type=OptionTypes.BOOLEAN,
required=True,
)
],
)
@check(admin_or_permissions(manage_guild=True))
async def _set_invitedel(self, ctx: SlashContext, active: int) -> None:
async def _set_invitedel(self, ctx: SlashContext, active: bool) -> None:
await ctx.defer()
self.update_settings("noinvite", bool(active), ctx.guild.id)
await ctx.send(f"Settings applied. Automatic invite active: {bool(active)}")
self.update_settings("noinvite", active, ctx.guild.id)
await ctx.send(f"Settings applied. Automatic invite active: {active}")
@cog_ext.cog_subcommand(
base="settings",

View file

@ -8,7 +8,6 @@ from dis_snek.models.discord.channel import GuildText
from dis_snek.models.discord.components import ActionRow, Select, SelectOption
from dis_snek.models.snek.application_commands import (
OptionTypes,
SlashCommandChoice,
slash_command,
slash_option,
)
@ -51,19 +50,14 @@ class TwitterCog(Scale):
@slash_option(
name="retweets",
description="Mirror re-tweets?",
opt_type=OptionTypes.STRING,
opt_type=OptionTypes.BOOLEAN,
required=False,
choices=[
SlashCommandChoice(name="Yes", value="Yes"),
SlashCommandChoice(name="No", value="No"),
],
)
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _twitter_follow(
self, ctx: InteractionContext, handle: str, channel: GuildText, retweets: str = "Yes"
self, ctx: InteractionContext, handle: str, channel: GuildText, retweets: bool = True
) -> None:
handle = handle.lower()
retweets = retweets == "Yes"
if len(handle) > 15:
await ctx.send("Invalid Twitter handle", ephemeral=True)
return
@ -176,16 +170,11 @@ class TwitterCog(Scale):
@slash_option(
name="retweets",
description="Mirror re-tweets?",
opt_type=OptionTypes.STRING,
opt_type=OptionTypes.BOOLEAN,
required=False,
choices=[
SlashCommandChoice(name="Yes", value="Yes"),
SlashCommandChoice(name="No", value="No"),
],
)
@check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _twitter_modify(self, ctx: InteractionContext, retweets: str) -> None:
retweets = retweets == "Yes"
async def _twitter_modify(self, ctx: InteractionContext, retweets: bool = True) -> None:
t = TwitterFollow.find(q(guild=ctx.guild.id))
twitters = []
async for twitter in t: