diff --git a/bot.py b/bot.py index 5ae68d9..359df68 100644 --- a/bot.py +++ b/bot.py @@ -6,6 +6,7 @@ A bot by turtlebasket import asyncio import json from urllib.request import urlopen, Request +import random import discord from discord.ext import commands from bot_utils import * @@ -111,8 +112,9 @@ 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])) + msg="{0}, here is your random shibe:".format(ctx.message.author.name) + url=json.loads(shibe_contents)[0] + await ctx.send(embed=imgfun(msg, url)) @bot.command(aliases=['latency']) async def ping(ctx): diff --git a/bot_utils.py b/bot_utils.py index e481bf1..3016b85 100644 --- a/bot_utils.py +++ b/bot_utils.py @@ -1,3 +1,4 @@ +import random import discord from discord.ext import commands import asyncio @@ -52,4 +53,9 @@ async def take_vote(ctx, question:str, wait_time, min_voters): return passed async def improper_usage(ctx): - await ctx.send("Improper command usage! See `>>help` for more.") \ No newline at end of file + await ctx.send("Improper command usage! See `>>help` for more.") + +def imgfun(msg:str, img_url:str): + return discord.Embed( + title=msg, color=random.randint(0, 16777215) + ).set_image(url=img_url) \ No newline at end of file diff --git a/servermanagement.py b/servermanagement.py deleted file mode 100644 index 5415912..0000000 --- a/servermanagement.py +++ /dev/null @@ -1,42 +0,0 @@ -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