Update mechanism should return appropriate messages now
This commit is contained in:
parent
e03d4ad637
commit
21b4eee3dc
16
bot.py
16
bot.py
|
|
@ -26,6 +26,10 @@ async def on_ready():
|
|||
await tree.sync(guild=discord.Object(id='745287426402156555'))
|
||||
print(f'Logged in as {client.user}')
|
||||
print('------')
|
||||
if data['update'] & data['update'] == 'pending':
|
||||
client.get_channel(1173561093579362305).send('Update done')
|
||||
write_json('update', 'none')
|
||||
|
||||
|
||||
@tree.command(name = 'cool', description = 'Check how cool you are!', guild=discord.Object(id='745287426402156555'))
|
||||
async def cool(ctx: discord.Interaction):
|
||||
|
|
@ -36,8 +40,8 @@ async def cool(ctx: discord.Interaction):
|
|||
@app_commands.checks.has_role(745295653651087381)
|
||||
async def update(ctx: discord.Interaction):
|
||||
await ctx.response.send_message('Updating, see you on the other side')
|
||||
write_json('update', 'pending')
|
||||
subprocess.run('./update.sh')
|
||||
await ctx.response.send_message('Done')
|
||||
|
||||
@update.error
|
||||
async def update_error(ctx: discord.Interaction, error):
|
||||
|
|
@ -45,4 +49,14 @@ async def update_error(ctx: discord.Interaction, error):
|
|||
text = "Sorry {}, you do not have permissions to do that!".format(ctx.user)
|
||||
await ctx.response.send_message(text)
|
||||
|
||||
def write_json(key: str, value: any):
|
||||
data[key] = value
|
||||
|
||||
if exists('config.local.json'):
|
||||
with open('config.local.json') as f:
|
||||
f.write(json.dumps(data))
|
||||
elif exists('config.json'):
|
||||
with open('config.json') as f:
|
||||
f.write(json.dumps(data))
|
||||
|
||||
client.run(data['token'])
|
||||
Loading…
Reference in New Issue
Block a user