As you know, going on the FiveM server browser just to see if your server/ another server is up is a pain sometimes, therefore i made this nice simple little script for people who use Red-DiscordBot on their Discord. How To Use: Simply create a .py file with any name you want and put it in the “cogs” folder of the bot, then copy this code in:
from discord.ext import commands
"""IllusiveTea's Custom cog that checks if a server is up!"""
def __init__(self, bot):
self.bot = bot
async def ss(self):
"""Checks if a server is up"""
sock = socket.socket(socket.AF_INET, socket.SOCK_STREAM)
result = sock.connect_ex(("PUT SERVER IP HERE", PORT)) #put your servers ip and port here! Default FiveM port is 30120
if result == 0:
await self.bot.say("Server is Currently: __**Online!**__")
await self.bot.say("Server is Currently: __**Offline**__ :frowning:.")
MAKE SURE TO PUT YOUR SERVERS IP AND PORT IN THE PLACES SPECIFIED!
Then head into discord and do [p]load “Put Created file name here E.G: servercheck” ([p] is your command prefix, like mine is a “.”) then you’re set! Simply do [p]ss and it will respond depending on if it is or not!
Images! (The version on my server hence the message, but you can set to whatever you want!)