Skip to content

Commit

Permalink
Fixed IDE errors for discord option
Browse files Browse the repository at this point in the history
close #648
  • Loading branch information
StephanAkkerman committed Aug 29, 2024
1 parent 49187dc commit 26cceb3
Show file tree
Hide file tree
Showing 6 changed files with 73 additions and 62 deletions.
10 changes: 4 additions & 6 deletions src/cogs/commands/analyze.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,6 @@
import datetime

import discord
from discord.commands import Option
from discord.commands.context import ApplicationContext
from discord.ext import commands

Expand All @@ -23,13 +22,12 @@ def __init__(self, bot: commands.Bot) -> None:
@commands.slash_command(
description="Request the current analysis for a stock ticker."
)
@discord.option(
"stock", type=str, description="Stock ticker, e.g. AAPL.", required=True
)
@log_command_usage
@conditional_role_decorator(config["COMMANDS"]["ANALYZE"]["ROLE"])
async def analyze(
self,
ctx: ApplicationContext,
stock: Option(str, description="Stock ticker, e.g. AAPL.", required=True),
) -> None:
async def analyze(self, ctx: ApplicationContext, stock: str) -> None:
"""
The analyze command is used to get the current analyst ratings for a stock ticker from benzinga.com.
Expand Down
12 changes: 5 additions & 7 deletions src/cogs/commands/earnings.py
Original file line number Diff line number Diff line change
@@ -1,18 +1,13 @@
##> Imports
from datetime import datetime

import discord
import pandas as pd
import pytz

# > 3rd Party Dependencies
import yfinance
from discord.commands import Option
from discord.commands.context import ApplicationContext
from discord.ext import commands

from constants.logger import logger

# Local dependencies
from util.confirm_stock import confirm_stock
from util.disc import log_command_usage

Expand All @@ -29,11 +24,14 @@ def __init__(self, bot: commands.Bot):
@commands.slash_command(
name="earnings", description="Gets next earnings date for a given stock."
)
@discord.option(
"stock", type=str, description="Stock ticker, e.g. AAPL.", required=True
)
@log_command_usage
async def earnings(
self,
ctx: ApplicationContext,
stock: Option(str, description="Stock ticker, e.g. AAPL.", required=True),
stock: str,
):
"""
Gets next earnings date for a given stock.
Expand Down
8 changes: 4 additions & 4 deletions src/cogs/commands/help.py
Original file line number Diff line number Diff line change
@@ -1,7 +1,4 @@
##> Imports
# > Discord dependencies
import discord
from discord.commands import Option
from discord.commands.context import ApplicationContext
from discord.ext import commands

Expand All @@ -19,11 +16,14 @@ def __init__(self, bot):
self.guild = None

@commands.slash_command(description="Receive information about a command.")
@discord.option(
"command", str, description="Command to get help for.", required=False
)
@log_command_usage
async def help(
self,
ctx: ApplicationContext,
command: Option(str, description="Command to get help for.", required=False),
command: str = None,
):
"""
Receive information about a command or channel
Expand Down
40 changes: 19 additions & 21 deletions src/cogs/commands/portfolio.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
import discord
import pandas as pd
from discord import Interaction, SelectOption
from discord.commands import Option, SlashCommandGroup
from discord.commands import SlashCommandGroup
from discord.commands.context import ApplicationContext
from discord.ext import commands
from discord.ui import Select, View
Expand Down Expand Up @@ -39,30 +39,28 @@ def update_portfolio_db(self, new_db):
@portfolios.command(
name="add", description="Add a cryptocurrency portfolio to the database."
)
@discord.option(
"exchange",
type=str,
description="The name of your crypto exchange.",
required=True,
)
@discord.option("key", type=str, description="Your API key.", required=True)
@discord.option("secret", type=str, description="Your API secret.", required=True)
@discord.option(
"passphrase",
type=str,
description="Your API passphrase (only used for Kucoin).",
required=False,
)
@log_command_usage
async def add(
self,
ctx: ApplicationContext,
exchange: Option(
str,
description="Provide the name of your crypto exchange.",
required=True,
),
key: Option(
str,
description="Provide your API key.",
required=True,
),
secret: Option(
str,
description="Provide your API secret.",
required=True,
),
passphrase: Option(
str,
description="Provide your API passphrase (only used for Kucoin).",
required=False,
),
exchange: str,
key: str,
secret: str,
passphrase: str,
) -> None:
"""
Adds your portfolio to the database.
Expand Down
6 changes: 4 additions & 2 deletions src/cogs/commands/sentiment.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,6 @@
import discord
import nltk
import pandas as pd
from discord.commands import Option
from discord.commands.context import ApplicationContext
from discord.ext import commands
from nltk.sentiment.vader import SentimentIntensityAnalyzer
Expand Down Expand Up @@ -66,11 +65,14 @@ def __init__(self, bot: commands.Bot) -> None:
@commands.slash_command(
description="Request the current sentiment for a stock ticker."
)
@discord.option(
"stock", type=str, description="Stock ticker, e.g. AAPL.", required=True
)
@log_command_usage
async def sentiment(
self,
ctx: ApplicationContext,
stock: Option(str, description="Stock ticker, i.e. AAPL.", required=True),
stock: str,
) -> None:
"""
This method is used to handle the sentiment command.
Expand Down
59 changes: 37 additions & 22 deletions src/cogs/commands/stock.py
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import discord
import pandas as pd
from discord.commands import Option, SlashCommandGroup
from discord.commands import SlashCommandGroup
from discord.commands.context import ApplicationContext
from discord.ext import commands

Expand Down Expand Up @@ -47,23 +48,31 @@ def update_assets_db(self, new_db):
update_db(new_db, "assets")

@stocks.command(name="add", description="Add a stock to your portfolio.")
@discord.option(
"ticker",
type=str,
description="The ticker of the stock e.g., AAPL.",
required=True,
)
@discord.option(
"buying_price",
type=str,
description="The price of the stock when you bought it, e.g., 106.40",
required=True,
)
@discord.option(
"amount",
type=str,
description="The amount of stocks that you own at this price, e.g., 2",
required=True,
)
@log_command_usage
async def add(
self,
ctx: ApplicationContext,
ticker: Option(
str, description="The ticker of the stock e.g., AAPL", required=True
),
buying_price: Option(
str,
description="The price of the stock when you bought it, e.g., 106.40",
required=True,
),
amount: Option(
str,
description="The amount of stocks that you own at this price, e.g., 2",
required=True,
),
ticker: str,
buying_price: str,
amount: str,
) -> None:
"""
Add stocks to your portfolio.
Expand Down Expand Up @@ -188,18 +197,24 @@ async def add(
@stocks.command(
name="remove", description="Remove a specific stock from your portfolio."
)
@discord.option(
"ticker",
type=str,
description="The ticker of the stock e.g., AAPL.",
required=True,
)
@discord.option(
"amount",
type=str,
description="The amount of stocks that you want to delete, e.g., 2",
required=False,
)
@log_command_usage
async def remove(
self,
ctx: ApplicationContext,
ticker: Option(
str, description="The ticker of the stock e.g., AAPL", required=True
),
amount: Option(
str,
description="The amount of stocks that you want to delete, e.g., 2",
required=False,
),
ticker: str,
amount: str,
) -> None:
"""
Usage:
Expand Down

0 comments on commit 26cceb3

Please sign in to comment.