forked from gooberinc/goober
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")
|
||||
])
|
||||
async def retrain_models(ctx, option: app_commands.Choice[str]):
|
||||
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"
|
||||
await retrain_single_server(ctx, server_id)
|
||||
|
||||
elif option.value == "all":
|
||||
await retrain_all_servers(ctx)
|
||||
|
||||
elif option.value == "select":
|
||||
await show_server_selection(ctx)
|
||||
if ctx.author.id == ownerid:
|
||||
if option.value == "current":
|
||||
server_id = ctx.guild.id if ctx.guild else "DM"
|
||||
await retrain_single_server(ctx, server_id)
|
||||
elif option.value == "all":
|
||||
await retrain_all_servers(ctx)
|
||||
elif option.value == "select":
|
||||
await show_server_selection(ctx)
|
||||
else:
|
||||
if ctx.guild and (ctx.author.guild_permissions.administrator or any(role.permissions.administrator for role in ctx.author.roles)):
|
||||
if option.value == "current":
|
||||
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):
|
||||
memory_file = f"memories/memory_{server_id}.json"
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue