Closed Horizon6053 closed 2 years ago
try: myserver.start() except: await ctx.send("Server couldn't open.")
Please, replace this code with:
try:
myserver.start()
except Exception as ex:
print(ex)
And then, send me output.
In that case I'll find out which error do you have.
Maybe, myserver contains None
so interpreter raises AttributeError
.
if serv.address == 'HorizonSmpDNK.aternos.me:12584':
Also, I don't recommend comparing full address,
because Aternos can change the port or, for example, move to other domain.
Use if serv.subdomain == 'HorizonSmpDNK': ...
ill try to do that! thanks!
what do "local variable 'myserver' referenced before assignment" means...
import discord import python_aternos from discord.ext import commands from python_aternos import Client
token = '' client = commands.Bot(command_prefix='$', help_command=None)
@client.event async def on_ready(): print(f'Logged in as {client.user}')
@client.command() async def start(ctx): try: aternos = Client.from_credentials("", "")
except Exception as e:
await ctx.send("Couldnt log in")
await ctx.send(f"Error {e}")
else:
servs = aternos.list_servers()
for serv in servs:
if serv.address == 'HorizonSmpDNK.aternos.me:12584':
myserver = serv
try:
myserver.start()
except Exception as ex:
print(ex)
else:
await ctx.send('await ctx.send("SERVER SUCESSFULLY OPENED!\nServer Address: HorizonSmpDNK.aternos.me:12584\nPort: 12584")')
client.run(token)
You try to start server before creating variable myserver
.
If condition always False (there's no server with that name) or for loop never starts (list_servers returns empty []
), myserver won't be declared!
myserver = None
for s in at.list_servers():
if s.subdomain == ...:
myserver = s
if s is not None:
myserver.start()
In your case, error caused by empty servers list.
It's a bug (#43 and #48), please, wait for a new version.
i need help so it keep showing me this error whenever i use webserver
and i found a python script so i copied it and then i ofcourse configured it and then after that its working pretty fine without wbeserver but it keep saying "Server couldn't open" this is the code:
yes i copied the code but it isnt working pls respond i really need help i've been stuck...
this is my plan so basically on discord if someone typied $start the server will start but instead it will just say "Server couldn't open" i tried $start many times... pls respond :(