Ignore implementation for time being

This commit is contained in:
Zeva Rose 2022-02-04 13:06:28 -07:00
parent 9647f9c746
commit e9500d6ce1

View file

@ -1,6 +1,7 @@
"""J.A.R.V.I.S. Settings Management Cog.""" """J.A.R.V.I.S. Settings Management Cog."""
from typing import Any from typing import Any
from dis_snek.models.snek.command import check
from discord import Role, TextChannel from discord import Role, TextChannel
from discord.ext import commands from discord.ext import commands
from discord.utils import find from discord.utils import find
@ -42,15 +43,15 @@ class SettingsCog(commands.Cog):
create_option( create_option(
name="channel", name="channel",
description="Modlog channel", description="Modlog channel",
option_type=7, opt_type=7,
required=True, required=True,
) )
], ],
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _set_modlog(self, ctx: SlashContext, channel: TextChannel) -> None: async def _set_modlog(self, ctx: SlashContext, channel: TextChannel) -> None:
if not isinstance(channel, TextChannel): if not isinstance(channel, TextChannel):
await ctx.send("Channel must be a TextChannel", hidden=True) await ctx.send("Channel must be a TextChannel", ephemeral=True)
return return
self.update_settings("modlog", channel.id, ctx.guild.id) self.update_settings("modlog", channel.id, ctx.guild.id)
await ctx.send(f"Settings applied. New modlog channel is {channel.mention}") await ctx.send(f"Settings applied. New modlog channel is {channel.mention}")
@ -64,15 +65,15 @@ class SettingsCog(commands.Cog):
create_option( create_option(
name="channel", name="channel",
description="Userlog channel", description="Userlog channel",
option_type=7, opt_type=7,
required=True, required=True,
) )
], ],
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _set_userlog(self, ctx: SlashContext, channel: TextChannel) -> None: async def _set_userlog(self, ctx: SlashContext, channel: TextChannel) -> None:
if not isinstance(channel, TextChannel): if not isinstance(channel, TextChannel):
await ctx.send("Channel must be a TextChannel", hidden=True) await ctx.send("Channel must be a TextChannel", ephemeral=True)
return return
self.update_settings("userlog", channel.id, ctx.guild.id) self.update_settings("userlog", channel.id, ctx.guild.id)
await ctx.send(f"Settings applied. New userlog channel is {channel.mention}") await ctx.send(f"Settings applied. New userlog channel is {channel.mention}")
@ -86,12 +87,12 @@ class SettingsCog(commands.Cog):
create_option( create_option(
name="amount", name="amount",
description="Amount of mentions (0 to disable)", description="Amount of mentions (0 to disable)",
option_type=4, opt_type=4,
required=True, required=True,
) )
], ],
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _set_massmention(self, ctx: SlashContext, amount: int) -> None: async def _set_massmention(self, ctx: SlashContext, amount: int) -> None:
await ctx.defer() await ctx.defer()
self.update_settings("massmention", amount, ctx.guild.id) self.update_settings("massmention", amount, ctx.guild.id)
@ -106,12 +107,12 @@ class SettingsCog(commands.Cog):
create_option( create_option(
name="role", name="role",
description="verified role", description="verified role",
option_type=8, opt_type=8,
required=True, required=True,
) )
], ],
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _set_verified(self, ctx: SlashContext, role: Role) -> None: async def _set_verified(self, ctx: SlashContext, role: Role) -> None:
await ctx.defer() await ctx.defer()
self.update_settings("verified", role.id, ctx.guild.id) self.update_settings("verified", role.id, ctx.guild.id)
@ -126,12 +127,12 @@ class SettingsCog(commands.Cog):
create_option( create_option(
name="role", name="role",
description="Unverified role", description="Unverified role",
option_type=8, opt_type=8,
required=True, required=True,
) )
], ],
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _set_unverified(self, ctx: SlashContext, role: Role) -> None: async def _set_unverified(self, ctx: SlashContext, role: Role) -> None:
await ctx.defer() await ctx.defer()
self.update_settings("unverified", role.id, ctx.guild.id) self.update_settings("unverified", role.id, ctx.guild.id)
@ -146,12 +147,12 @@ class SettingsCog(commands.Cog):
create_option( create_option(
name="active", name="active",
description="Active?", description="Active?",
option_type=4, opt_type=4,
required=True, required=True,
) )
], ],
) )
@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: int) -> None:
await ctx.defer() await ctx.defer()
self.update_settings("noinvite", bool(active), ctx.guild.id) self.update_settings("noinvite", bool(active), ctx.guild.id)
@ -163,7 +164,7 @@ class SettingsCog(commands.Cog):
name="modlog", name="modlog",
description="Unset modlog channel", description="Unset modlog channel",
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _unset_modlog(self, ctx: SlashContext) -> None: async def _unset_modlog(self, ctx: SlashContext) -> None:
self.delete_settings("modlog", ctx.guild.id) self.delete_settings("modlog", ctx.guild.id)
await ctx.send("Setting removed.") await ctx.send("Setting removed.")
@ -174,7 +175,7 @@ class SettingsCog(commands.Cog):
name="userlog", name="userlog",
description="Unset userlog channel", description="Unset userlog channel",
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _unset_userlog(self, ctx: SlashContext) -> None: async def _unset_userlog(self, ctx: SlashContext) -> None:
self.delete_settings("userlog", ctx.guild.id) self.delete_settings("userlog", ctx.guild.id)
await ctx.send("Setting removed.") await ctx.send("Setting removed.")
@ -185,7 +186,7 @@ class SettingsCog(commands.Cog):
name="massmention", name="massmention",
description="Unet massmention amount", description="Unet massmention amount",
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _massmention(self, ctx: SlashContext) -> None: async def _massmention(self, ctx: SlashContext) -> None:
await ctx.defer() await ctx.defer()
self.delete_settings("massmention", ctx.guild.id) self.delete_settings("massmention", ctx.guild.id)
@ -197,7 +198,7 @@ class SettingsCog(commands.Cog):
name="verified", name="verified",
description="Unset verified role", description="Unset verified role",
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _verified(self, ctx: SlashContext) -> None: async def _verified(self, ctx: SlashContext) -> None:
await ctx.defer() await ctx.defer()
self.delete_settings("verified", ctx.guild.id) self.delete_settings("verified", ctx.guild.id)
@ -209,14 +210,14 @@ class SettingsCog(commands.Cog):
name="unverified", name="unverified",
description="Unset unverified role", description="Unset unverified role",
) )
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _unverified(self, ctx: SlashContext) -> None: async def _unverified(self, ctx: SlashContext) -> None:
await ctx.defer() await ctx.defer()
self.delete_settings("unverified", ctx.guild.id) self.delete_settings("unverified", ctx.guild.id)
await ctx.send("Setting removed.") await ctx.send("Setting removed.")
@cog_ext.cog_subcommand(base="settings", name="view", description="View settings") @cog_ext.cog_subcommand(base="settings", name="view", description="View settings")
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _view(self, ctx: SlashContext) -> None: async def _view(self, ctx: SlashContext) -> None:
settings = Setting.objects(guild=ctx.guild.id) settings = Setting.objects(guild=ctx.guild.id)
@ -237,7 +238,7 @@ class SettingsCog(commands.Cog):
value = "||`[redacted]`||" value = "||`[redacted]`||"
elif setting.setting == "rolegiver": elif setting.setting == "rolegiver":
value = "" value = ""
for role in setting.value: for _role in setting.value:
nvalue = find(lambda x: x.id == value, ctx.guild.roles) nvalue = find(lambda x: x.id == value, ctx.guild.roles)
if value: if value:
value += "\n" + nvalue.mention value += "\n" + nvalue.mention
@ -250,7 +251,7 @@ class SettingsCog(commands.Cog):
await ctx.send(embed=embed) await ctx.send(embed=embed)
@cog_ext.cog_subcommand(base="settings", name="clear", description="Clear all settings") @cog_ext.cog_subcommand(base="settings", name="clear", description="Clear all settings")
@admin_or_permissions(manage_guild=True) @check(admin_or_permissions(manage_guild=True))
async def _clear(self, ctx: SlashContext) -> None: async def _clear(self, ctx: SlashContext) -> None:
deleted = Setting.objects(guild=ctx.guild.id).delete() deleted = Setting.objects(guild=ctx.guild.id).delete()
await ctx.send(f"Guild settings cleared: `{deleted is not None}`") await ctx.send(f"Guild settings cleared: `{deleted is not None}`")
@ -258,4 +259,4 @@ class SettingsCog(commands.Cog):
def setup(bot: commands.Bot) -> None: def setup(bot: commands.Bot) -> None:
"""Add SettingsCog to J.A.R.V.I.S.""" """Add SettingsCog to J.A.R.V.I.S."""
bot.add_cog(SettingsCog(bot)) SettingsCog(bot)