Update database bot.py
This commit is contained in:
parent
28d4cf4f84
commit
e99ceb015f
1 changed files with 38 additions and 30 deletions
|
@ -24,41 +24,47 @@ client = commands.Bot(command_prefix='.')
|
||||||
@client.command()
|
@client.command()
|
||||||
async def addcharacter(ctx):
|
async def addcharacter(ctx):
|
||||||
await ctx.send("adding to database please wait")
|
await ctx.send("adding to database please wait")
|
||||||
await ctx.message.attachments[0].save("newcharacter.zip")
|
try:
|
||||||
|
await ctx.message.attachments[0].save("newcharacter.zip")
|
||||||
|
|
||||||
zf = ZipFile('newcharacter.zip', 'r')
|
zf = ZipFile('newcharacter.zip', 'r')
|
||||||
zf.extractall('public/singlecharacter')
|
zf.extractall('public/singlecharacter')
|
||||||
zf.close()
|
zf.close()
|
||||||
if os.path.exists("newcharacter.zip"):
|
if os.path.exists("newcharacter.zip"):
|
||||||
os.remove("newcharacter.zip")
|
os.remove("newcharacter.zip")
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if os.path.exists("public/characters.zip"):
|
if os.path.exists("public/characters.zip"):
|
||||||
os.remove("public/characters.zip")
|
os.remove("public/characters.zip")
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
shutil.make_archive('public/characters', 'zip', 'public/singlecharacter')
|
shutil.make_archive('public/characters', 'zip', 'public/singlecharacter')
|
||||||
await ctx.send("added to database")
|
await ctx.send("added to database")
|
||||||
|
except BaseException:
|
||||||
|
await ctx.send("something went wrong! this probably means you didn't attach a file or discord api is broken")
|
||||||
|
|
||||||
|
|
||||||
@client.command()
|
@client.command()
|
||||||
async def addsound(ctx):
|
async def addsound(ctx):
|
||||||
await ctx.send("adding to database please wait")
|
await ctx.send("adding to database please wait")
|
||||||
await ctx.message.attachments[0].save("newsound.zip")
|
try:
|
||||||
|
await ctx.message.attachments[0].save("newsound.zip")
|
||||||
|
|
||||||
zf = ZipFile('newsound.zip', 'r')
|
zf = ZipFile('newsound.zip', 'r')
|
||||||
zf.extractall('public/singlesound')
|
zf.extractall('public/singlesound')
|
||||||
zf.close()
|
zf.close()
|
||||||
if os.path.exists("newsound.zip"):
|
if os.path.exists("newsound.zip"):
|
||||||
os.remove("newsound.zip")
|
os.remove("newsound.zip")
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
if os.path.exists("public/sounds.zip"):
|
if os.path.exists("public/sounds.zip"):
|
||||||
os.remove("public/sounds.zip")
|
os.remove("public/sounds.zip")
|
||||||
else:
|
else:
|
||||||
pass
|
pass
|
||||||
shutil.make_archive('public/sounds', 'zip', 'public/singlesound')
|
shutil.make_archive('public/sounds', 'zip', 'public/singlesound')
|
||||||
await ctx.send("added to database")
|
await ctx.send("added to database")
|
||||||
|
except BaseException:
|
||||||
|
await ctx.send("something went wrong! this probably means you didn't attach a file or discord api is broken")
|
||||||
|
|
||||||
@client.command()
|
@client.command()
|
||||||
async def setip(ctx):
|
async def setip(ctx):
|
||||||
|
@ -70,12 +76,14 @@ async def setip(ctx):
|
||||||
@client.command()
|
@client.command()
|
||||||
async def getchrasset(ctx):
|
async def getchrasset(ctx):
|
||||||
weburl = ctx.message.content[13:]
|
weburl = ctx.message.content[13:]
|
||||||
await ctx.send("http://fierce-push.auto.playit.gg:53368/singlecharacter/"+str(weburl))
|
betterweburl = weburl.replace(" ", "%20")
|
||||||
|
await ctx.send("http://fierce-push.auto.playit.gg:53368/singlecharacter/"+str(betterweburl))
|
||||||
|
|
||||||
@client.command()
|
@client.command()
|
||||||
async def getsound(ctx):
|
async def getsound(ctx):
|
||||||
sound = ctx.message.content[10:]
|
sound = ctx.message.content[10:]
|
||||||
await ctx.send("http://fierce-push.auto.playit.gg:53368/singlesound/"+str(sound))
|
bettersound = sound.replace(" ", "%20")
|
||||||
|
await ctx.send("http://fierce-push.auto.playit.gg:53368/singlesound/"+str(bettersound))
|
||||||
|
|
||||||
@client.command()
|
@client.command()
|
||||||
async def downloadcharacter(ctx):
|
async def downloadcharacter(ctx):
|
||||||
|
|
Reference in a new issue