Adding trader reset command to the bot

This commit is contained in:
Luke Robles 2024-10-17 15:03:14 -07:00
parent 63f5bdf388
commit d30bcb85ab
4 changed files with 46 additions and 9 deletions

View File

@ -1,4 +1,3 @@
from bs4 import BeautifulSoup
from discord import option from discord import option
from discord.ext import commands from discord.ext import commands
import discord import discord

View File

@ -18,6 +18,51 @@ class Tarkov(commands.Cog):
tarkov = discord.SlashCommandGroup("tarkov", "Tarkov related commands") tarkov = discord.SlashCommandGroup("tarkov", "Tarkov related commands")
@tarkov.command(
guild_ids=core_utils.my_guilds,
name="traders",
description="Time until trader resets",
)
async def trader_resets(self, ctx: commands.Context):
import requests
from datetime import datetime
from datetime import timezone
await ctx.defer()
# Define the target date and time
embed = discord.Embed(
description="-------", color=discord.Color.blue(), type="rich"
)
embed.set_author(name="Trader Reset Times")
embed.set_thumbnail(url="https://i.ytimg.com/vi/8He5q7qOzNw/maxresdefault.jpg")
times = requests.get(
"https://tarkovbot.eu/tools/pve/trader-resets/gettimes"
).json()
for time in times:
target_time = datetime.fromisoformat(
time["resetTime"].replace("000Z", "+00:00")
)
# Get the current time in UTC
current_time = datetime.now(timezone.utc)
# Calculate the difference
time_difference = target_time - current_time
# Convert the difference to minutes
minutes_until = time_difference.total_seconds() / 60
embed.add_field(
name=time["name"],
value=f"{minutes_until:.2f} minutes",
inline=True,
)
await ctx.send_followup(embed=embed)
@tarkov.command( @tarkov.command(
guild_ids=core_utils.my_guilds, guild_ids=core_utils.my_guilds,
name="lottery", name="lottery",

View File

@ -1,11 +1,6 @@
from bs4 import BeautifulSoup from discord.ext import commands
from discord import option
from discord.ext import commands, tasks
import discord import discord
import json
import os
import queue import queue
import requests
import threading import threading
import core_utils import core_utils

View File

@ -1,8 +1,6 @@
from bs4 import BeautifulSoup from bs4 import BeautifulSoup
import json
import queue import queue
import requests import requests
import threading
def query_wiki(letter, q: queue.Queue): def query_wiki(letter, q: queue.Queue):