Added update command and permission check
This commit is contained in:
parent
3a0c2ac8ab
commit
d48020c3b4
17
bot.py
17
bot.py
|
|
@ -3,8 +3,8 @@ import random
|
||||||
import subprocess
|
import subprocess
|
||||||
import json
|
import json
|
||||||
import discord
|
import discord
|
||||||
from discord.ext import commands
|
|
||||||
from discord import app_commands
|
from discord import app_commands
|
||||||
|
from discord.ext.commands import has_role, MissingRole
|
||||||
|
|
||||||
|
|
||||||
with open('config.json', 'r') as f:
|
with open('config.json', 'r') as f:
|
||||||
|
|
@ -34,9 +34,16 @@ async def cool(ctx):
|
||||||
cool_factor = round(random.uniform(0, 100), 2)
|
cool_factor = round(random.uniform(0, 100), 2)
|
||||||
await ctx.response.send_message(f'{ctx.author} is {cool_factor}% cool!')
|
await ctx.response.send_message(f'{ctx.author} is {cool_factor}% cool!')
|
||||||
|
|
||||||
# @bot.command()
|
@tree.command(name = 'update', description = 'Pulls the latest version from the repository', )
|
||||||
# async def update(ctx):
|
@has_role(745295653651087381)
|
||||||
# subprocess.Popen('./update.sh')
|
async def update(ctx):
|
||||||
# print(f'Updating, see you on the other side')
|
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):
|
||||||
|
text = "Sorry {}, you do not have permissions to do that!".format(ctx.message.author)
|
||||||
|
await ctx.response.send_message(text)
|
||||||
|
|
||||||
client.run(data['token'])
|
client.run(data['token'])
|
||||||
Loading…
Reference in New Issue
Block a user