This repository has been archived on 2023-10-23. You can view files and clone it, but cannot push or open issues or pull requests.
filesystem-bot/database bot.py

61 lines
1.7 KiB
Python
Raw Normal View History

2021-01-25 21:52:36 +00:00
import discord
from discord.ext import commands
from time import sleep
import os
import datetime
import wget
from zipfile import ZipFile
import shutil
client = commands.Bot(command_prefix='.')
@client.command()
async def addcharacter(ctx):
2021-01-26 01:07:02 +00:00
await ctx.send("adding to database please wait")
2021-01-25 21:52:36 +00:00
await ctx.message.attachments[0].save("newcharacter.zip")
zf = ZipFile('newcharacter.zip', 'r')
zf.extractall('public/singlecharacter')
2021-01-25 21:52:36 +00:00
zf.close()
if os.path.exists("newcharacter.zip"):
2021-01-25 22:00:02 +00:00
os.remove("newcharacter.zip")
else:
pass
if os.path.exists("public/characters.zip"):
2021-01-25 22:00:02 +00:00
os.remove("public/characters.zip")
else:
pass
shutil.make_archive('public/characters', 'zip', 'public/singlecharacter')
await ctx.send("added to database")
2021-01-26 01:07:02 +00:00
@client.command()
async def addsound(ctx):
2021-01-26 01:07:02 +00:00
await ctx.send("adding to database please wait")
await ctx.message.attachments[0].save("newsound.zip")
zf = ZipFile('newsound.zip', 'r')
zf.extractall('public/singlesound')
zf.close()
if os.path.exists("newsound.zip"):
2021-01-25 22:00:02 +00:00
os.remove("newsound.zip")
else:
pass
if os.path.exists("public/sounds.zip"):
2021-01-25 22:00:02 +00:00
os.remove("public/sounds.zip")
else:
pass
shutil.make_archive('public/sounds', 'zip', 'public/singlesound')
2021-01-25 21:52:36 +00:00
await ctx.send("added to database")
2021-01-26 01:07:02 +00:00
@client.command()
async def setip(ctx):
ip = userInput = ctx.message.content[7:]
with open("public/serverlist.txt", "w+") as hisc:
hisc.write(str(ip)+":best bois courthouse")
await ctx.send("changed ip to "+str(ip))
2021-01-25 21:52:36 +00:00
2021-01-25 21:54:12 +00:00
client.run('botid')