Closed ph3onixleader closed 3 years ago
The code would be nice to see what you're doing! Also the command being used would be good too!
In order for us to help you, you'll have to start by providing something that we can help with... The code that is causing your issue would be a good start. Keep in mind that we aren't here to help with the discord library that you might be struggling with; you will have to show why your code is failing with server.query(). Honestly, my first guess is that there is probably a firewall issue #72, but it's just that... a guess... Because you haven't shared any error messages or context! Help us to help you!
import discord import os from replit import db from KEEP_ALIVE import KEEP_ALIVE from mcstatus import MinecraftServer
client = discord.Client()
@client.event async def on_ready(): print("Pilot {0.user} is ready for battle".format(client))
server = MinecraftServer.lookup("no")
@client.event async def on_message(message): if message.author == client.user: return
if message.content.startswith(">server"): status = server.status() await message.channel.send("The server has {0} players and replied in {1} ms".format(status.players.online, status.latency))
if message.content.startswith(">ping"): latency = server.ping() await message.channel.send("The server replied in {0} ms".format(latency))
if message.content.startswith(">help"): await message.channel.send("you can use these commands:?help, ?ping, ?players, ?server side note:things may not work 100% so dont expect it to be 10/10 quality")
if message.content.startswith(">players"): query = server.query() await message.channel.startswith("The server has the following players online: {0}".format(", ".join(query.players.names)))
KEEP_ALIVE() client.run(os.getenv("TOKEN"))
if there is anything else you need then just ask (apologise for not posting code before)
error code: Traceback (most recent call last): File "/opt/virtualenvs/python3/lib/python3.8/site-packages/discord/client.py", line 343, in _run_event await coro(*args, **kwargs) File "main.py", line 33, in on_message query = server.query() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/mcstatus/server.py", line 106, in query raise exception File "/opt/virtualenvs/python3/lib/python3.8/site-packages/mcstatus/server.py", line 101, in query querier.handshake() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/mcstatus/querier.py", line 32, in handshake packet = self._read_packet() File "/opt/virtualenvs/python3/lib/python3.8/site-packages/mcstatus/querier.py", line 25, in _read_packet packet.receive(self.connection.read(self.connection.remaining())) File "/opt/virtualenvs/python3/lib/python3.8/site-packages/mcstatus/protocol/connection.py", line 181, in read result.extend(self.socket.recvfrom(self.remaining())[0]) socket.timeout: timed ou
I guessed it right; see #72. There's a network/firewall issue preventing access to the query port.
I am coding a private discord bot for me and my friends and I have been having issues with it as everything works fine until I hit my command that sends the info about players and I was wondering if there was any solution to it. If u need code i can provide it when I'm free!(side note:I am using repl so that my friend doesn't have to run it on his pc)