add approve button to moderations, add reset

Kaveen Kumarasinghe 2 years ago
parent 8b9d816f08
commit 2ff7cb1a3b

@ -261,7 +261,7 @@ class ModerationsService(discord.Cog, name="ModerationsService"):
await ctx.defer(ephemeral=True)
# Case for printing the current config
if not any(all_args):
if not any(all_args) and config_type != "reset":
await ctx.respond(
ephemeral=True,
embed=await self.build_moderation_settings_embed(
@ -308,6 +308,11 @@ class ModerationsService(discord.Cog, name="ModerationsService"):
self.set_delete_set(ctx.guild_id, new_delete_set)
await self.restart_moderations_service(ctx)
elif config_type == "reset":
self.set_delete_set(ctx.guild_id, self.default_delete_set)
self.set_warn_set(ctx.guild_id, self.default_warn_set)
await self.restart_moderations_service(ctx)
async def moderations_test_command(
self, ctx: discord.ApplicationContext, prompt: str
):

@ -63,7 +63,7 @@ class Settings_autocompleter:
"""gets valid values for the type option"""
print(f"The value is {ctx.value}")
return [
value for value in ["warn", "delete"] if value.startswith(ctx.value.lower())
value for value in ["warn", "delete", "reset"] if value.startswith(ctx.value.lower())
]
async def get_value_alert_id_channel(self, ctx: discord.AutocompleteContext):

@ -147,8 +147,6 @@ class Moderation:
@staticmethod
def determine_moderation_result(text, response, warn_set, delete_set):
# warn_set = ThresholdSet(0.005, 0.05, 0.05, 0.91, 0.1, 0.04, 0.1)
# delete_set = ThresholdSet(0.26, 0.26, 0.1, 0.95, 0.03, 0.85, 0.4)
warn_result, flagged_warn = warn_set.moderate(text, response)
delete_result, flagged_delete = delete_set.moderate(text, response)
@ -304,11 +302,29 @@ class ModerationAdminView(discord.ui.View):
)
)
component_number += 1
self.add_item(
ApproveMessageButton(
self.message, self.moderation_message, component_number
)
)
component_number += 1
if deleted_message:
self.add_item(
KickUserButton(self.message, self.moderation_message, component_number)
)
class ApproveMessageButton(discord.ui.Button["ModerationAdminView"]):
def __init__(self, message, moderation_message, current_num):
super().__init__(style=discord.ButtonStyle.green, label="Approve")
self.message = message
self.moderation_message = moderation_message
self.current_num = current_num
async def callback(self, interaction: discord.Interaction):
# Remove reactions on the message, delete the moderation message
await self.message.clear_reactions()
await self.moderation_message[0].delete()
class DeleteMessageButton(discord.ui.Button["ModerationAdminView"]):
def __init__(self, message, moderation_message, current_num):

Loading…
Cancel
Save