Смотрите видео ниже, чтобы узнать, как установить наш сайт в качестве веб-приложения на домашнем экране.
Примечание: this_feature_currently_requires_accessing_site_using_safari
Способ актуален для серверов, работающих 24/7 (держащихся на VDS, например).
const http = require('http');
const server = http.createServer(function(request, response) {
response.writeHead(200, {"Content-Type": "text/html"});
response.write(`${mp.players.length}/${mp.players.size}`);
response.end();
});
server.listen(8080);
console.log('\nМониторинг запущен. Онлайн передан в Discord.');
require('./discordOnline.js')
pip install disnake
pip install requests
import disnake
import requests
from disnake.ext import tasks
intents = disnake.Intents.all()
bot = commands.Bot(command_prefix='.', intents=intents)
@tasks.loop(seconds=120)
async def update_channel_name():
guild_id = ID_ВАШЕГО_DISCORD_СЕРВЕРА
channel_id = ID_КАНАЛА_ДЛЯ_ОТОБРАЖЕНИЯ_ОНЛАЙНА
# id вводить без каких-либо кавычек, просто цифры.
guild = bot.get_guild(guild_id)
channel = guild.get_channel(channel_id)
url = "http://localhost:8080/"
response = requests.get(url)
if response.status_code == 200:
source_code = response.text
if guild and channel:
await channel.edit(name=f'Онлайн сервера: {source_code}')
@bot.event
async def on_connect():
update_channel_name.start()
bot.run('ТОКЕН_ВАШЕГО_БОТА')
python main.py