DiscordBot/bot.py
2023-11-13 12:23:55 +01:00

38 lines
903 B
Python

from genericpath import exists
import random
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 cool(ctx):
cool_factor = round(random.uniform(0, 100), 2)
await ctx.send(f'{ctx.author} is {cool_factor}% cool!')
@bot.command()
async def update(ctx):
subprocess.Popen('./update.sh')
print(f'Updating, see you on the other side')
bot.run(data['token'])