forked from sass/tipibot
Change admin command permissions
This commit is contained in:
@@ -13,6 +13,7 @@ from pathlib import Path
|
||||
import discord
|
||||
from discord import app_commands
|
||||
|
||||
from core.admin import bot_admin_check
|
||||
import strings as S
|
||||
|
||||
|
||||
@@ -32,7 +33,7 @@ def register_ops_admin_commands(
|
||||
) -> None:
|
||||
@tree.command(name="status", description=S.CMD["status"])
|
||||
@app_commands.guild_only()
|
||||
@app_commands.default_permissions(manage_guild=True)
|
||||
@bot_admin_check()
|
||||
async def cmd_status(interaction: discord.Interaction):
|
||||
mem = process.memory_info()
|
||||
cpu = process.cpu_percent(interval=0.1)
|
||||
@@ -95,7 +96,7 @@ def register_ops_admin_commands(
|
||||
|
||||
@tree.command(name="sync", description=S.CMD["sync"])
|
||||
@app_commands.guild_only()
|
||||
@app_commands.default_permissions(manage_guild=True)
|
||||
@bot_admin_check()
|
||||
async def cmd_sync(interaction: discord.Interaction):
|
||||
await interaction.response.defer(ephemeral=True)
|
||||
tree.copy_global_to(guild=guild_obj)
|
||||
@@ -107,7 +108,7 @@ def register_ops_admin_commands(
|
||||
|
||||
@tree.command(name="restart", description=S.CMD["restart"])
|
||||
@app_commands.guild_only()
|
||||
@app_commands.default_permissions(manage_guild=True)
|
||||
@bot_admin_check()
|
||||
async def cmd_restart(interaction: discord.Interaction):
|
||||
restart_file.write_text(json.dumps({"channel_id": interaction.channel_id}), encoding="utf-8")
|
||||
await interaction.response.send_message(S.MSG_RESTARTING, ephemeral=True)
|
||||
@@ -117,7 +118,7 @@ def register_ops_admin_commands(
|
||||
|
||||
@tree.command(name="shutdown", description=S.CMD["shutdown"])
|
||||
@app_commands.guild_only()
|
||||
@app_commands.default_permissions(manage_guild=True)
|
||||
@bot_admin_check()
|
||||
async def cmd_shutdown(interaction: discord.Interaction):
|
||||
await interaction.response.send_message(S.MSG_SHUTTING_DOWN, ephemeral=True)
|
||||
log.info("/shutdown triggered by %s", interaction.user)
|
||||
@@ -125,7 +126,7 @@ def register_ops_admin_commands(
|
||||
|
||||
@tree.command(name="pause", description=S.CMD["pause"])
|
||||
@app_commands.guild_only()
|
||||
@app_commands.default_permissions(manage_guild=True)
|
||||
@bot_admin_check()
|
||||
async def cmd_pause(interaction: discord.Interaction):
|
||||
paused = not get_paused()
|
||||
set_paused(paused)
|
||||
|
||||
Reference in New Issue
Block a user