From 3b23bd1a0b4b3dbb1ace60d6d3a870ea234e579e Mon Sep 17 00:00:00 2001 From: Philipp Date: Mon, 7 Oct 2024 22:47:24 +0200 Subject: [PATCH] bump requirements, update to new interactions syntax --- requirements.txt | 8 ++++---- src/main.py | 29 ++++++++++++++--------------- 2 files changed, 18 insertions(+), 19 deletions(-) diff --git a/requirements.txt b/requirements.txt index 5c4ccee..1ac0678 100644 --- a/requirements.txt +++ b/requirements.txt @@ -1,5 +1,5 @@ -discord-py-interactions==4.3.1 +discord-py-interactions==5.13.2 steamid==1.0.2 -python-dotenv==0.21.0 -mysql-connector-python==8.0.30 -loguru==0.6.0 +python-dotenv==1.0.1 +mysql-connector-python==8.0.29 +loguru==0.7.2 diff --git a/src/main.py b/src/main.py index feeb295..c71af9a 100644 --- a/src/main.py +++ b/src/main.py @@ -1,8 +1,8 @@ import os import sys import signal -import interactions +from interactions import Client, Intents, listen, slash_command, slash_option, OptionType, SlashContext from database import Database from dotenv import load_dotenv from steamid import SteamID @@ -38,7 +38,7 @@ def main(args): password = os.getenv('MYSQL_PASSWORD') db = os.getenv('MYSQL_DATABASE') - bot = interactions.Client(token=token) + bot = Client(intents=Intents.DEFAULT) con = Database(host, user, password, db) @@ -50,21 +50,20 @@ def main(args): logger.info(f"Skipping database init...") pass - @bot.command( + @slash_command( name="reserve_slot", description="Claim your reserved slot on the DM Server", - scope=433600034983116810, - options=[ - interactions.Option( - name="steamid", - description="Please provide your SteamID, from https://steamid.xyz/", - type=interactions.OptionType.STRING, - required=True, - ), - ], - ) + scopes=[433600034983116810], + ) - async def reserve_slot(ctx: interactions.CommandContext, steamid: str): + @slash_option( + name="steamid", + description="Please provide your SteamID, from https://steamid.xyz/", + required=True, + opt_type=OptionType.STRING, + ) + + async def reserve_slot(ctx: SlashContext, steamid: str): channel = ctx.channel.id user = ctx.user @@ -97,7 +96,7 @@ def main(args): await ctx.send(f"You have already claimed a reserved slot!", ephemeral=True) logger.debug(f"{steam_id.steam2(1)} or User {user.username} ({user.id}) is already in the database.") - bot.start() + bot.start(token) while True: logger.info("Trying graceful shutdown...")