Skip to content
Permalink
Browse files
Added uptime and moved variables
  • Loading branch information
hollan84 committed May 22, 2020
1 parent 1abeadc commit cc4ed8728f2e11e34a88e4d1fabab08a1808aab7
Show file tree
Hide file tree
Showing 6 changed files with 24 additions and 5 deletions.
@@ -1,6 +1,7 @@
import os
import discord
import status
import datetime

from mcstatus import MinecraftServer
from datetime import datetime
@@ -13,7 +14,7 @@ import settings
import developer
import bot_functions as functions

from variables import *
from python_variables import *

copyfile(".env", "lib/.env") #Copies the env file to the lib directory

@@ -75,8 +76,11 @@ async def on_message(message):
elif ('botinfo') in message_command:
msg = "Minecraft Bot - Version {}\n".format(str(os.environ['VERSION']))
msg = "{}Total Discord Servers: {}\n".format(msg, database.get_total("*"))
msg = "{}{}\n".format(msg, functions.uptime())
#msg = "{}Total Minecraft Servers: {}\n".format(msg, database.get_total("minecraft_server"))
#msg = "{}Percentage of servers using maps: {}%\n".format(msg, str((int(database.get_total("map"))/int(database.get_total("minecraft_server"))*100)))
elif ('uptime') in message_command:
msg = functions.uptime()
elif ('developer') in message_command:
msg = developer.developer_check(user_message, message.author, guild_id)
elif ('status') in message_command:
@@ -2,7 +2,8 @@ import database

from googletrans import Translator

from variables import *
from python_variables import *
from uptime import *

def help(user_message, prefix, guild_id):

@@ -27,4 +28,14 @@ def language(user_message, guild_id):
user_message = user_message[len(prefix):]
user_message = translator.translate(user_message, src=database.read_database("language", guild_id), dest='en') #Translate the message to English
user_message = "{}{}".format(prefix,user_message.text) #Rebuild message
return user_message.lower() #Returns the lowercase message
return user_message.lower() #Returns the lowercase message

def plural(int_value):
if str(int_value) == "1":
return ""
return "s"

def uptime():
curr_time = datetime.datetime.now()
uptime = curr_time - start_time
return "Bot Uptime: {} day{}, {} hour{}, {} minute{} and {} second{}".format(uptime.days, plural(uptime.days), uptime.seconds//3600, plural(uptime.seconds//3600), uptime.seconds//60, plural(uptime.seconds//60), uptime.seconds%60, plural(uptime.seconds%60))
@@ -2,7 +2,7 @@ import sqlite3
from sqlite3 import Error
import os

from variables import *
#from python_variables import *

def create_initial_connection(db_file):
conn = None
@@ -83,6 +83,6 @@ def main():
create_table(conn, create_player_table_sql)
create_table(conn, create_dev_table_sql)

add_primary_developer(conn, PrimaryDeveloper)
add_primary_developer(conn, "AlastairHolland#6538")

conn.commit()
@@ -19,6 +19,7 @@ commands = { #Sets the commands for the help
"support" : "Join our support server",
"botinfo" : "Get information on the bot",
"version" : "Gives the bot release version",
"uptime" : "Gives the uptime of the bot",
"donate" : "Allows you to donate to the development of this project"
}

@@ -0,0 +1,2 @@
import datetime
start_time = datetime.datetime.now()
1 run.py
@@ -4,6 +4,7 @@ def run():
from lib import librarySetup
from lib import databaseSetup
from lib import shell
from lib import uptime
librarySetup.checkLibraries() #Check and install libraries
databaseSetup.main() #Create database

0 comments on commit cc4ed87

Please sign in to comment.