From b13a20626828d6eaa44b844434e907905538af04 Mon Sep 17 00:00:00 2001 From: turtlebasket Date: Tue, 3 Sep 2019 22:14:23 -0700 Subject: [PATCH] you're welcome shelby --- bot.py | 13 +++++++++++++ servermanagement.py | 42 ++++++++++++++++++++++++++++++++++++++++++ 2 files changed, 55 insertions(+) create mode 100644 servermanagement.py diff --git a/bot.py b/bot.py index 883470a..5ae68d9 100644 --- a/bot.py +++ b/bot.py @@ -5,6 +5,7 @@ A bot by turtlebasket import asyncio import json +from urllib.request import urlopen, Request import discord from discord.ext import commands from bot_utils import * @@ -69,6 +70,11 @@ async def help(ctx): name=">>ping", value="Get bot latency." ) + + embed.add_field( + name=">>shibe", + value="shibe :dog: :eyes" + ) await ctx.send(embed=embed) @@ -100,6 +106,13 @@ async def addEmote(ctx, emote_name: str): file_bytes = await ctx.message.attachments[0].read() await ctx.guild.create_custom_emoji(name=emote_name, image=file_bytes) +@bot.command() +async def shibe(ctx): + # with urllib.request.urlopen("http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true") as json_return: + with urlopen(Request(url="http://shibe.online/api/shibes?count=1&urls=true&httpsUrls=true", headers={'User-Agent': 'Mozilla/5.0'})) as json_return: + shibe_contents = json_return.read() + await ctx.send(embed=discord.Embed( + title="{0}, here is your random shibe:".format(ctx.message.author.name)).set_image(url=json.loads(shibe_contents)[0])) @bot.command(aliases=['latency']) async def ping(ctx): diff --git a/servermanagement.py b/servermanagement.py new file mode 100644 index 0000000..5415912 --- /dev/null +++ b/servermanagement.py @@ -0,0 +1,42 @@ +import sqlite3 +connection = sqlite3.connect('storage.db') + +c = connection.cursor() + +c.execute + + +""" +import json +import bot + +class server_obj: + ID = 0 + + MUTE_VOTE_TIME = 30 + MIN_MUTE_VOTERS = 4 # should be 3 + MUTE_TIME = 600 # 10 mins + + KICK_VOTE_TIME = 300 + MIN_KICK_VOTERS = 6 + + BAN_VOTE_TIME = 1200 + MIN_BAN_VOTERS = 8 + + def __init__(self, id: int): + self.ID = id + +def new_server_json(id: int): + json.dump(server_obj(id), "server_data/{}.json".format(str(id))) + +def update_attribute(server: int, attrib: str, value): + try: + with open('server_data/{}.json'.format(str(server)), 'r+') as target: + json_file = json.load(target) + json_file["{}".format(attrib)] = value + json_file.close() + except FileNotFoundError: + new_server_json(id) + +def load_attribute(): +""" \ No newline at end of file