add ability for server admins to retrain the bot periodically
This commit is contained in:
parent
ddfd67df5c
commit
7877db4785
1 changed files with 17 additions and 12 deletions
29
bot.py
29
bot.py
|
@ -401,18 +401,23 @@ async def send_message(ctx, message=None, embed=None, file=None, edit=False, mes
|
||||||
app_commands.Choice(name="Select servers to retrain", value="select")
|
app_commands.Choice(name="Select servers to retrain", value="select")
|
||||||
])
|
])
|
||||||
async def retrain_models(ctx, option: app_commands.Choice[str]):
|
async def retrain_models(ctx, option: app_commands.Choice[str]):
|
||||||
if ctx.author.id != ownerid:
|
if ctx.author.id == ownerid:
|
||||||
return await ctx.send("You don't have permission to use this command.", ephemeral=True)
|
if option.value == "current":
|
||||||
|
server_id = ctx.guild.id if ctx.guild else "DM"
|
||||||
if option.value == "current":
|
await retrain_single_server(ctx, server_id)
|
||||||
server_id = ctx.guild.id if ctx.guild else "DM"
|
elif option.value == "all":
|
||||||
await retrain_single_server(ctx, server_id)
|
await retrain_all_servers(ctx)
|
||||||
|
elif option.value == "select":
|
||||||
elif option.value == "all":
|
await show_server_selection(ctx)
|
||||||
await retrain_all_servers(ctx)
|
else:
|
||||||
|
if ctx.guild and (ctx.author.guild_permissions.administrator or any(role.permissions.administrator for role in ctx.author.roles)):
|
||||||
elif option.value == "select":
|
if option.value == "current":
|
||||||
await show_server_selection(ctx)
|
server_id = ctx.guild.id
|
||||||
|
await retrain_single_server(ctx, server_id)
|
||||||
|
else:
|
||||||
|
await ctx.send("You can only retrain the current server.", ephemeral=True)
|
||||||
|
else:
|
||||||
|
await ctx.send("You don't have permission to use this command.", ephemeral=True)
|
||||||
|
|
||||||
async def retrain_single_server(ctx, server_id):
|
async def retrain_single_server(ctx, server_id):
|
||||||
memory_file = f"memories/memory_{server_id}.json"
|
memory_file = f"memories/memory_{server_id}.json"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue