From ff9e1a1f38f46dd188afc0c1df4111d1780a0e0e Mon Sep 17 00:00:00 2001 From: root Date: Wed, 19 Oct 2022 23:49:33 +0200 Subject: [PATCH] Init --- .gitignore | 1 + bot.py | 36 ++++++++++++++++++++++++++++++++++++ config.json | 3 +++ update.sh | 8 ++++++++ 4 files changed, 48 insertions(+) create mode 100644 .gitignore create mode 100644 bot.py create mode 100644 config.json create mode 100755 update.sh diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..51b9aa7 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +config.local.json \ No newline at end of file diff --git a/bot.py b/bot.py new file mode 100644 index 0000000..7410b97 --- /dev/null +++ b/bot.py @@ -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']) \ No newline at end of file diff --git a/config.json b/config.json new file mode 100644 index 0000000..e66e4ae --- /dev/null +++ b/config.json @@ -0,0 +1,3 @@ +{ + "token": "Your token here" +} \ No newline at end of file diff --git a/update.sh b/update.sh new file mode 100755 index 0000000..ee8b691 --- /dev/null +++ b/update.sh @@ -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 \ No newline at end of file