Role check v2

This commit is contained in:
Marco Loewe 2023-11-14 10:57:52 +01:00
parent 1d6f9f0ea8
commit 80180f9b46

6
bot.py
View File

@ -4,8 +4,6 @@ import subprocess
import json
import discord
from discord import app_commands
from discord.ext.commands import has_role, MissingRole
with open('config.json', 'r') as f:
data = json.load(f)
@ -35,14 +33,14 @@ async def cool(ctx):
await ctx.response.send_message(f'{ctx.author} is {cool_factor}% cool!')
@tree.command(name = 'update', description = 'Pulls the latest version from the repository', guild=discord.Object(id='745287426402156555'))
@has_role(745295653651087381)
@app_commands.checks.has_role(745295653651087381)
async def update(ctx):
subprocess.Popen('./update.sh')
print(f'Updating, see you on the other side')
@update.error
async def update_error(ctx: discord.Interaction, error):
if isinstance(error, MissingRole):
if isinstance(error, discord.app_commands.MissingRole):
text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
await ctx.response.send_message(text)