Skip to content

Commit

Permalink
Merge pull request #11 from NeverScapeAlone/v1.1.0-alpha
Browse files Browse the repository at this point in the history
v1.1.0
  • Loading branch information
Ferrariic authored Jul 13, 2022
2 parents c651291 + 32ccf5c commit 7e6c52f
Show file tree
Hide file tree
Showing 2 changed files with 37 additions and 1 deletion.
37 changes: 36 additions & 1 deletion src/bot.py
Original file line number Diff line number Diff line change
@@ -1,9 +1,9 @@
from dis import disco
import logging
import discord
from discord.ext import tasks
import config
import json
import time
from functions import get_url, post_url

logger = logging.getLogger(__name__)
Expand Down Expand Up @@ -40,8 +40,43 @@ async def on_message(message):
return


async def run_active_queues():
route = (
config.BASE + f"V1/discord/get-active-queues?token={config.DISCORD_ROUTE_TOKEN}"
)

response = await get_url(route=route)
channel = client.get_channel(config.ACTIVE_QUEUES_CHANNEL)
messages = await channel.history(limit=5).flatten()

embed = discord.Embed(
title="Active Queues", description=f"Updated: <t:{int(time.time())}:R>"
)

if "detail" in response.keys():
if response["detail"] == "bad token":
logging.warning(response["detail"])
return
if response["detail"] == "no information":
embed.add_field(name="Active Queues", value="None", inline=False)
else:
for activity in response:
count = response[activity]
embed.add_field(name=activity, value=count, inline=False)

if len(messages) > 0:
message = messages[0]
await message.edit(embed=embed)
return

await channel.send(embed=embed)
return


@tasks.loop(seconds=5)
async def manage_channels():
await run_active_queues()

route = (
config.BASE
+ f"V1/discord/get-active-matches?token={config.DISCORD_ROUTE_TOKEN}"
Expand Down
1 change: 1 addition & 0 deletions src/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@
TICKET_BOT = 508391840525975553
GUILD_ID = 985750991846666284
MATCH_CATEGORY = 993321356005486592
ACTIVE_QUEUES_CHANNEL = 996565302202605619
# BASE = "http://127.0.0.1:8000/"
BASE = "http://touchgrass.online:5000/"

Expand Down

0 comments on commit 7e6c52f

Please sign in to comment.