This commit is contained in:
root 2022-10-19 23:49:33 +02:00
commit ff9e1a1f38
4 changed files with 48 additions and 0 deletions

1
.gitignore vendored Normal file
View File

@ -0,0 +1 @@
config.local.json

36
bot.py Normal file
View File

@ -0,0 +1,36 @@
from genericpath import exists
import subprocess
import json
import discord
from discord.ext import commands
with open('config.json', 'r') as f:
data = json.load(f)
if exists('config.local.json'):
with open('config.local.json') as f:
data = json.load(f)
intents = discord.Intents.default()
intents.message_content = True
description = '''Bot to end all bots'''
bot = commands.Bot(command_prefix='?', description=description, intents=intents)
@bot.event
async def on_ready():
print(f'Logged in as {bot.user}')
print('------')
@bot.command()
async def add(ctx, left: int, right: int):
await ctx.send(left + right)
@bot.command()
async def update(ctx):
subprocess.Popen('./update.sh')
print(f'Updating, see you on the other side')
bot.run(data['token'])

3
config.json Normal file
View File

@ -0,0 +1,3 @@
{
"token": "Your token here"
}

8
update.sh Executable file
View File

@ -0,0 +1,8 @@
#!/bin/bash
sleep 5
pkill -f 'bot.py'
echo 'Updating...'
git pull origin master
echo 'Finished. Starting bot...'
python3.10 bot.py