Skip to content
Permalink
Browse files
Added Settings
  • Loading branch information
hollan84 committed May 3, 2020
1 parent ce97eba commit 58af3ab21cde41f45c10a944d3c2b3be9d514cad
Show file tree
Hide file tree
Showing 3 changed files with 68 additions and 11 deletions.
@@ -1,7 +1,7 @@
# Minecraft Discord
Welcome to my GitHub

This is a Discord bot that you host yourself (tutorial below) that can tell you the status of your (or any public) Minecraft server and tlel you the players online.
This is a Discord bot that you host yourself (tutorial below) that can tell you the status of your (or any public) Minecraft server and lists the players online.
More functions listed below.

## README in development
@@ -1,24 +1,79 @@
def environment():
import os.path
import os

'''Prevents overwriting of the environment file'''
settingList = ["Token", "Server IP", "Port", "Command Prefix", "Custom File"]
if os.path.isfile('.env'): #Checks to see if there is an environment file
overwrite = input("Would you like to overwrite your current credentials? (y/n)")
overwrite = input("Would you like to change your current settings? (y/n) > ")
overwrite = overwrite.lower() #Makes the input string lowercase
if overwrite == "y" or overwrite == "yes":
print("Creating new credientials... \n")
print("\nChoose settings to change")
for i in settingList:
print("{} - {}".format((settingList.index(i)+1), i))
settingsChoice = input("\nInput the numbers of the settings you want to change\nYou can change multiple numbers by typing more than one (Example: 12345)\n > ")
else:
return #Exit function
else:
settingsChoice = "12345"

'''Gets information'''
token = input("Input your bot token here > ")
serverIP = input("Input your server URL/IP here > ")
port = input("Input your bot port here (If you don't know it, leave blank) > ")
if port == "":
port = "25565" #Default Minecraft server port
if str(settingList.index("Token")+1) in settingsChoice:
token = input("Input your bot token here > ")
else:
token = os.environ['TOKEN']
if str(settingList.index("Server IP")+1) in settingsChoice:
serverIP = input("Input your server URL/IP here > ")
else:
serverIP = os.environ['SERVER']
if str(settingList.index("Port")+1) in settingsChoice:
port = input("Input your bot port here (If you don't know it, leave blank) > ")
if port == "":
port = "25565" #Default Minecraft server port
else:
port = os.environ['PORT']
if str(settingList.index("Command Prefix")+1) in settingsChoice:
commandPrefix = input("If you want a custom command prefix, enter is here (Default is '?' - Leave bank for default)> ")
if commandPrefix == "":
commandPrefix = "?"
else:
commandPrefix = os.environ['PREFIX']
if str(settingList.index("Custom File")+1) in settingsChoice:
customFile = input("Would you like a custom file to add your code to? (y/n) > ")
customFile = customFile.lower()
if customFile == "y" or customFile == "yes":
if os.path.isfile("Custom.py"):
newCustom = input("Do you want to overwrite the current custom file? (y/n) > ")
newCustom = newCustom.lower()
if newCustom == "y" or newCustom == "yes":
oldFile = open("customCode.py", "r")
oldCode = oldFile.read()
oldFile.close()
x = 0
copied = False
while copied == False:
backupPath = "oldCustom/custom{}.py".format(x)
if not os.path.isfile(backupPath):
backupFile = open(backupPath, "w")
backupFile.write(oldCode)
copied = True
x = x + 1
template = open("templates/customTemplate.py", "r")
customFile = open("customCode.py", "w")
customFile.write(template.read())
customFile.close()
template.close()
else:
template = open("templates/customTemplate.py", "r")
customFile = open("customCode.py", "w")
customFile.write(template.read())
customFile.close()
template.close()
custom = "TRUE"
else:
custom = os.environ['CUSTOM']

'''Concantinate into a string'''
data = "TOKEN={}\nSERVER={}\nPORT={}".format(token,serverIP,port) #Sets the format of the data
data = "TOKEN={}\nSERVER={}\nPORT={}\nPREFIX={}\nCUSTOM={}".format(token,serverIP,port,commandPrefix,custom) #Sets the format of the data

'''Write data to the .env file'''
creds = open(".env", "w")
@@ -39,4 +94,5 @@ def environment():
if tryAgain == "y" or tryAgain == "yes":
environment()
else:
return
return
environment()
@@ -0,0 +1 @@
#Test

0 comments on commit 58af3ab

Please sign in to comment.