mirror of
https://github.com/Cog-Creators/Red-DiscordBot.git
synced 2025-11-06 03:08:55 -05:00
[V3 Launcher] Show version in main menu (#1810)
* [V3 Launcher] Show version in main menu * Fix syntax * Fix typo * Make text underlined * Show if red is outdated
This commit is contained in:
parent
edadd8f2fd
commit
9f2ed694ce
@ -5,9 +5,11 @@ import subprocess
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import asyncio
|
import asyncio
|
||||||
|
import aiohttp
|
||||||
|
|
||||||
import pkg_resources
|
import pkg_resources
|
||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
|
from distutils.version import StrictVersion
|
||||||
from redbot.setup import (
|
from redbot.setup import (
|
||||||
basic_setup,
|
basic_setup,
|
||||||
load_existing_config,
|
load_existing_config,
|
||||||
@ -16,6 +18,7 @@ from redbot.setup import (
|
|||||||
create_backup,
|
create_backup,
|
||||||
save_config,
|
save_config,
|
||||||
)
|
)
|
||||||
|
from redbot.core import __version__
|
||||||
from redbot.core.utils import safe_delete
|
from redbot.core.utils import safe_delete
|
||||||
from redbot.core.cli import confirm
|
from redbot.core.cli import confirm
|
||||||
|
|
||||||
@ -384,12 +387,27 @@ def debug_info():
|
|||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
|
|
||||||
|
|
||||||
|
async def is_outdated():
|
||||||
|
red_pypi = "https://pypi.python.org/pypi/Red-DiscordBot"
|
||||||
|
async with aiohttp.ClientSession() as session:
|
||||||
|
async with session.get("{}/json".format(red_pypi)) as r:
|
||||||
|
data = await r.json()
|
||||||
|
new_version = data["info"]["version"]
|
||||||
|
return StrictVersion(new_version) > StrictVersion(__version__), new_version
|
||||||
|
|
||||||
|
|
||||||
def main_menu():
|
def main_menu():
|
||||||
if IS_WINDOWS:
|
if IS_WINDOWS:
|
||||||
os.system("TITLE Red - Discord Bot V3 Launcher")
|
os.system("TITLE Red - Discord Bot V3 Launcher")
|
||||||
clear_screen()
|
clear_screen()
|
||||||
|
loop = asyncio.get_event_loop()
|
||||||
|
outdated, new_version = loop.run_until_complete(is_outdated())
|
||||||
while True:
|
while True:
|
||||||
print(INTRO)
|
print(INTRO)
|
||||||
|
print("\033[4mCurrent version:\033[0m {}".format(__version__))
|
||||||
|
if outdated:
|
||||||
|
print("Red is outdated. {} is available.".format(new_version))
|
||||||
|
print("")
|
||||||
print("1. Run Red w/ autorestart in case of issues")
|
print("1. Run Red w/ autorestart in case of issues")
|
||||||
print("2. Run Red")
|
print("2. Run Red")
|
||||||
print("3. Update Red")
|
print("3. Update Red")
|
||||||
@ -418,13 +436,12 @@ def main_menu():
|
|||||||
basic_setup()
|
basic_setup()
|
||||||
wait()
|
wait()
|
||||||
elif choice == "5":
|
elif choice == "5":
|
||||||
asyncio.get_event_loop().run_until_complete(remove_instance_interaction())
|
loop.run_until_complete(remove_instance_interaction())
|
||||||
wait()
|
wait()
|
||||||
elif choice == "6":
|
elif choice == "6":
|
||||||
debug_info()
|
debug_info()
|
||||||
elif choice == "7":
|
elif choice == "7":
|
||||||
while True:
|
while True:
|
||||||
loop = asyncio.get_event_loop()
|
|
||||||
clear_screen()
|
clear_screen()
|
||||||
print("==== Reinstall Red ====")
|
print("==== Reinstall Red ====")
|
||||||
print(
|
print(
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user