mirror of
https://github.com/deadcxap/YandexMusicDiscordBot.git
synced 2026-01-09 07:21:53 +03:00
feat: Add servers count api calls.
This commit is contained in:
@@ -1,8 +1,10 @@
|
||||
import os
|
||||
import logging
|
||||
from aiohttp import ClientSession
|
||||
|
||||
import discord
|
||||
from discord.ext.commands import Bot
|
||||
from discord.ext import tasks
|
||||
|
||||
intents = discord.Intents.default()
|
||||
bot = Bot(intents=intents)
|
||||
@@ -18,6 +20,22 @@ async def on_ready():
|
||||
logging.info("Bot's ready!")
|
||||
await bot.change_presence(activity=discord.Activity(type=discord.ActivityType.listening, name="/voice vibe"))
|
||||
|
||||
@tasks.loop(seconds=3600)
|
||||
async def update_server_count():
|
||||
# Don't update server count in debug mode
|
||||
if os.getenv('DEBUG') == 'True':
|
||||
return
|
||||
|
||||
async with ClientSession() as session:
|
||||
if token := os.getenv('PROMO_TOKEN_1'):
|
||||
res = await session.post(
|
||||
'https://api.server-discord.com/v2/bots/1325795708019806250/stats',
|
||||
headers={'Authorization': token},
|
||||
data={'servers': len(bot.guilds), 'shards': bot.shard_count or 1}
|
||||
)
|
||||
if not res.ok:
|
||||
logging.error(f'Failed to update server count 1: {res.status} {await res.text()}')
|
||||
|
||||
if __name__ == '__main__':
|
||||
from dotenv import load_dotenv
|
||||
load_dotenv()
|
||||
|
||||
Reference in New Issue
Block a user