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( @slash_option(
name="active", name="active",
description="Active bans", description="Active bans",
opt_type=OptionTypes.INTEGER, opt_type=OptionTypes.BOOLEAN,
required=False, required=False,
choices=[SlashCommandChoice(name="Yes", value=1), SlashCommandChoice(name="No", value=0)],
) )
@check(admin_or_permissions(Permissions.BAN_MEMBERS)) @check(admin_or_permissions(Permissions.BAN_MEMBERS))
async def _bans_list(self, ctx: InteractionContext, btype: int = 0, active: int = 1) -> None: async def _bans_list(
active = bool(active) self, ctx: InteractionContext, btype: int = 0, active: bool = True
) -> None:
types = [0, "perm", "temp", "soft"] types = [0, "perm", "temp", "soft"]
search = {"guild": ctx.guild.id} search = {"guild": ctx.guild.id}
if active: 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.discord.user import User
from dis_snek.models.snek.application_commands import ( from dis_snek.models.snek.application_commands import (
OptionTypes, OptionTypes,
SlashCommandChoice,
slash_command, slash_command,
slash_option, slash_option,
) )
@ -66,17 +65,11 @@ class WarningCog(ModcaseCog):
@slash_option( @slash_option(
name="active", name="active",
description="View active only", description="View active only",
opt_type=OptionTypes.INTEGER, opt_type=OptionTypes.BOOLEAN,
required=False, required=False,
choices=[
SlashCommandChoice(name="Yes", value=1),
SlashCommandChoice(name="No", value=0),
],
) )
@check(admin_or_permissions(Permissions.MANAGE_GUILD)) @check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _warnings(self, ctx: InteractionContext, user: User, active: bool = 1) -> None: async def _warnings(self, ctx: InteractionContext, user: User, active: bool = True) -> None:
active = bool(active)
warnings = ( warnings = (
await Warning.find( await Warning.find(
user=user.id, 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.discord.modal import InputText, Modal, TextStyles
from dis_snek.models.snek.application_commands import ( from dis_snek.models.snek.application_commands import (
OptionTypes, OptionTypes,
SlashCommandChoice,
slash_command, slash_command,
slash_option, slash_option,
) )
@ -37,19 +36,14 @@ class RemindmeCog(Scale):
@slash_option( @slash_option(
name="private", name="private",
description="Send as DM?", description="Send as DM?",
opt_type=OptionTypes.STRING, opt_type=OptionTypes.BOOLEAN,
required=False, required=False,
choices=[
SlashCommandChoice(name="Yes", value="y"),
SlashCommandChoice(name="No", value="n"),
],
) )
async def _remindme( async def _remindme(
self, self,
ctx: InteractionContext, ctx: InteractionContext,
private: str = "n", private: bool = False,
) -> None: ) -> None:
private = private == "y"
modal = Modal( modal = Modal(
title="Set your reminder!", title="Set your reminder!",
components=[ components=[

View file

@ -150,16 +150,16 @@ class SettingsCog(Scale):
create_option( create_option(
name="active", name="active",
description="Active?", description="Active?",
opt_type=4, opt_type=OptionTypes.BOOLEAN,
required=True, required=True,
) )
], ],
) )
@check(admin_or_permissions(manage_guild=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() await ctx.defer()
self.update_settings("noinvite", bool(active), ctx.guild.id) self.update_settings("noinvite", active, ctx.guild.id)
await ctx.send(f"Settings applied. Automatic invite active: {bool(active)}") await ctx.send(f"Settings applied. Automatic invite active: {active}")
@cog_ext.cog_subcommand( @cog_ext.cog_subcommand(
base="settings", 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.discord.components import ActionRow, Select, SelectOption
from dis_snek.models.snek.application_commands import ( from dis_snek.models.snek.application_commands import (
OptionTypes, OptionTypes,
SlashCommandChoice,
slash_command, slash_command,
slash_option, slash_option,
) )
@ -51,19 +50,14 @@ class TwitterCog(Scale):
@slash_option( @slash_option(
name="retweets", name="retweets",
description="Mirror re-tweets?", description="Mirror re-tweets?",
opt_type=OptionTypes.STRING, opt_type=OptionTypes.BOOLEAN,
required=False, required=False,
choices=[
SlashCommandChoice(name="Yes", value="Yes"),
SlashCommandChoice(name="No", value="No"),
],
) )
@check(admin_or_permissions(Permissions.MANAGE_GUILD)) @check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _twitter_follow( 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: ) -> None:
handle = handle.lower() handle = handle.lower()
retweets = retweets == "Yes"
if len(handle) > 15: if len(handle) > 15:
await ctx.send("Invalid Twitter handle", ephemeral=True) await ctx.send("Invalid Twitter handle", ephemeral=True)
return return
@ -176,16 +170,11 @@ class TwitterCog(Scale):
@slash_option( @slash_option(
name="retweets", name="retweets",
description="Mirror re-tweets?", description="Mirror re-tweets?",
opt_type=OptionTypes.STRING, opt_type=OptionTypes.BOOLEAN,
required=False, required=False,
choices=[
SlashCommandChoice(name="Yes", value="Yes"),
SlashCommandChoice(name="No", value="No"),
],
) )
@check(admin_or_permissions(Permissions.MANAGE_GUILD)) @check(admin_or_permissions(Permissions.MANAGE_GUILD))
async def _twitter_modify(self, ctx: InteractionContext, retweets: str) -> None: async def _twitter_modify(self, ctx: InteractionContext, retweets: bool = True) -> None:
retweets = retweets == "Yes"
t = TwitterFollow.find(q(guild=ctx.guild.id)) t = TwitterFollow.find(q(guild=ctx.guild.id))
twitters = [] twitters = []
async for twitter in t: async for twitter in t: