You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
@client.event
async def on_ready():
print(f'{client.user} está online!')
voice_channels = client.guilds[0].voice_channels
channel1 = next((vc for vc in voice_channels if vc.name == "Servidor Minecraft"), None)
channel2 = next((vc for vc in voice_channels if vc.name == "Jogadores Online"), None)
if not channel1:
category = client.guilds[0].categories[0]
channel1 = await category.create_voice_channel("Servidor Minecraft")
if not channel2:
category = client.guilds[0].categories[0]
channel2 = await category.create_voice_channel("Jogadores Online")
client.loop.create_task(update_status(channel1, channel2))
async def update_status(channel1, channel2):
while True:
try:
host, port = "###.enxada.host", #####
with mcipc.query.Client(host, port) as client:
status = client.full_stat()
online_players = status['players']['online']
max_players = status['players']['max']
await channel1.edit(name=f"🟢 Servidor Online: {online_players}/{max_players}")
await channel2.edit(name=f"🟢 {online_players}/{max_players} Jogadores Online")
except Exception as e:
# Em caso de erro, mostrar mensagem no console
print(f"Erro ao atualizar status do servidor: {e}")
# Esperar 10 minutos antes de atualizar novamente
await asyncio.sleep(600)
@client.command()
async def status(ctx):
await ctx.send("Adicionado Status do servidor")
I can't understand what I did wrong. :(
import discord
import mcipc.query
import asyncio
import time
from discord.ext import commands, tasks
from key import token
intents = discord.Intents.default()
intents.members = True
client = commands.Bot(command_prefix='!', intents=intents)
TOKEN = token.get("TOKEN")
@client.event
async def on_ready():
print(f'{client.user} está online!')
async def update_status(channel1, channel2):
while True:
try:
host, port = "###.enxada.host", #####
with mcipc.query.Client(host, port) as client:
status = client.full_stat()
@client.command()
async def status(ctx):
await ctx.send("Adicionado Status do servidor")
@client.command()
async def ping(ctx):
await ctx.send('Pong! {0}'.format(round(bot.latency, 1)))
client.run(TOKEN)
The text was updated successfully, but these errors were encountered: