Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions techsupport_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,7 +402,7 @@ async def get_log_channel_from_guild(

# File config loading functions

def load_file_config(self, validate: bool = True):
def load_file_config(self, validate: bool = True) -> None:
"""Loads the config yaml file into a bot object.

Args:
Expand All @@ -423,7 +423,7 @@ def load_file_config(self, validate: bool = True):
for subsection in ["required"]:
self.validate_bot_config_subsection("bot_config", subsection)

def validate_bot_config_subsection(self, section: str, subsection: str):
def validate_bot_config_subsection(self, section: str, subsection: str) -> None:
"""Loops through a config subsection to check for missing values.

Args:
Expand Down Expand Up @@ -969,7 +969,7 @@ async def can_run(self, ctx: commands.Context, *, call_once=False) -> bool:

# IRC Stuff

async def start_irc(self):
async def start_irc(self) -> None:
"""Starts the IRC connection in a seperate thread"""
irc_config = getattr(self.file_config.api, "irc")
main_loop = asyncio.get_running_loop()
Expand Down
6 changes: 3 additions & 3 deletions techsupport_bot/botlogging/delayed.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@ def __init__(self, *args, **kwargs):
self.__send_queue = None
super().__init__(*args, **kwargs)

async def send_log(self, *args, **kwargs):
async def send_log(self, *args, **kwargs) -> None:
"""Adds a log to the queue
Does nothing different than the Logger send_log function()
Will disregard debug logs if debug is off
Expand All @@ -36,11 +36,11 @@ async def send_log(self, *args, **kwargs):

await self.__send_queue.put(super().send_log(*args, **kwargs))

def register_queue(self):
def register_queue(self) -> None:
"""Registers the asyncio.Queue object to make delayed logging possible"""
self.__send_queue = asyncio.Queue(maxsize=self.queue_size)

async def run(self):
async def run(self) -> None:
"""A forever loop that pulls from the queue and then waits based on the config"""
while True:
try:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/animal.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Loading the animal plugin"""

await bot.add_cog(Animals(bot=bot))
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -753,7 +753,7 @@ async def notify_for_application_change(
interaction: discord.Interaction,
application: bot.models.Applications,
member: discord.Member,
):
) -> None:
"""Notifies:
- The invoker
- The user
Expand Down
4 changes: 2 additions & 2 deletions techsupport_bot/commands/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Registers the BotInfo Cog"""
await bot.add_cog(BotInfo(bot=bot))

Expand All @@ -27,7 +27,7 @@ class BotInfo(cogs.BaseCog):

@commands.check(auxiliary.bot_admin_check_context)
@commands.command(name="bot", description="Provides bot info")
async def get_bot_data(self, ctx):
async def get_bot_data(self, ctx) -> None:
"""Gets various data about the bot.

This is a command and should be accessed via Discord.
Expand Down
4 changes: 2 additions & 2 deletions techsupport_bot/commands/burn.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Method to add burn command to config."""
await bot.add_cog(Burn(bot=bot))

Expand Down Expand Up @@ -80,7 +80,7 @@ async def burn_command(
description="Declares the user's last message as a BURN!",
usage="@user",
)
async def burn(self, ctx: commands.Context, user_to_match: discord.Member):
async def burn(self, ctx: commands.Context, user_to_match: discord.Member) -> None:
"""The only purpose of this function is to accept input from discord

Args:
Expand Down
12 changes: 6 additions & 6 deletions techsupport_bot/commands/chatgpt.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Registers the extension"""

# Don't load without the API key
Expand All @@ -36,7 +36,7 @@ class ChatGPT(cogs.BaseCog):

API_URL = "https://api.openai.com/v1/chat/completions"

async def preconfig(self):
async def preconfig(self) -> None:
"""Sets up the dict"""
self.history = expiringdict.ExpiringDict(
max_len=1000,
Expand Down Expand Up @@ -93,7 +93,7 @@ async def call_api(self, ctx: commands.Context, api_key: str, prompt: str) -> st
description="Issues a prompt to the ChatGPT API",
usage="[prompt]",
)
async def gpt(self, ctx: commands.Context, *, prompt: str):
async def gpt(self, ctx: commands.Context, *, prompt: str) -> None:
"""Pushes a prompt to the OpenAI API for ChatGPT

Args:
Expand Down Expand Up @@ -160,7 +160,7 @@ async def gpt(self, ctx: commands.Context, *, prompt: str):
brief="Executes a ChatGPT utility command",
description="Executes a ChatGPT utility command",
)
async def gptutil(self, ctx: commands.Context):
async def gptutil(self, ctx: commands.Context) -> None:
"""Defines the Gptutil command group for history management

Args:
Expand All @@ -176,7 +176,7 @@ async def gptutil(self, ctx: commands.Context):
brief="Clears history",
description="Clears your ChatGPT conversation history",
)
async def clear_history(self, ctx: commands.Context):
async def clear_history(self, ctx: commands.Context) -> None:
"""Command to clear the invokers result history

Args:
Expand Down Expand Up @@ -219,7 +219,7 @@ async def clear_history(self, ctx: commands.Context):
brief="Gets history",
description="Gets your ChatGPT conversation history",
)
async def get_history(self, ctx: commands.Context):
async def get_history(self, ctx: commands.Context) -> None:
"""Command to get the history of the invoker

Args:
Expand Down
8 changes: 4 additions & 4 deletions techsupport_bot/commands/commandcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,7 +12,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Registers the CommandControl Cog"""
await bot.add_cog(CommandControl(bot=bot))

Expand All @@ -28,7 +28,7 @@ class CommandControl(cogs.BaseCog):
brief="Executes a commands bot command",
description="Executes a commands bot command",
)
async def command_group(self, ctx: commands.Context):
async def command_group(self, ctx: commands.Context) -> None:
"""The bare .command command. This does nothing but generate the help message

Args:
Expand All @@ -42,7 +42,7 @@ async def command_group(self, ctx: commands.Context):
@command_group.command(
name="enable", description="Enables a command by name", usage="[command-name]"
)
async def enable_command(self, ctx, *, command_name: str):
async def enable_command(self, ctx, *, command_name: str) -> None:
"""Enables a command by name.

This is a command and should be accessed via Discord.
Expand Down Expand Up @@ -75,7 +75,7 @@ async def enable_command(self, ctx, *, command_name: str):
@command_group.command(
name="disable", description="Disables a command by name", usage="[command-name]"
)
async def disable_command(self, ctx, *, command_name: str):
async def disable_command(self, ctx, *, command_name: str) -> None:
"""Disables a command by name.

This is a command and should be accessed via Discord.
Expand Down
4 changes: 2 additions & 2 deletions techsupport_bot/commands/conch.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Method to add conch to the config in discord bot."""
await bot.add_cog(MagicConch(bot=bot))

Expand Down Expand Up @@ -86,6 +86,6 @@ async def conch_command(self, ctx: commands.Context, question: str = "") -> None
description="Asks the Magic Conch (8ball) a question",
usage="[question]",
)
async def ask_question(self, ctx: commands.Context, *, question: str = ""):
async def ask_question(self, ctx: commands.Context, *, question: str = "") -> None:
"""Method for how the conch command works for the bot."""
await self.conch_command(ctx, question)
22 changes: 13 additions & 9 deletions techsupport_bot/commands/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Method to add burn command to config."""
await bot.add_cog(ConfigControl(bot=bot))

Expand All @@ -23,7 +23,7 @@ class ConfigControl(cogs.BaseCog):
brief="Issues a config command",
description="Issues a config command",
)
async def config_command(self, ctx):
async def config_command(self, ctx) -> None:
"""The parent config command.

This is a command and should be accessed via Discord.
Expand All @@ -43,13 +43,13 @@ async def config_command(self, ctx):
description="Edits guild config by uploading JSON",
usage="|uploaded-json|",
)
async def patch_config(self, ctx):
async def patch_config(self, ctx: commands.Context) -> None:
"""Displays the current config to the user.

This is a command and should be accessed via Discord.

parameters:
ctx (discord.ext.Context): the context object for the message
ctx (commands.Context): the context object for the message
"""
config = self.bot.guild_configs[str(ctx.guild.id)]

Expand Down Expand Up @@ -112,13 +112,15 @@ async def patch_config(self, ctx):
description="Enables an extension for the guild by name",
usage="[extension-name]",
)
async def enable_extension(self, ctx, extension_name: str):
async def enable_extension(
self, ctx: commands.Context, extension_name: str
) -> None:
"""Enables an extension for the guild.

This is a command and should be accessed via Discord.

parameters:
ctx (discord.ext.Context): the context object for the message
ctx (commands.Context): the context object for the message
extension_name (str): the extension subname to enable
"""
if not (
Expand Down Expand Up @@ -160,13 +162,15 @@ async def enable_extension(self, ctx, extension_name: str):
description="Disables an extension for the guild by name",
usage="[extension-name]",
)
async def disable_extension(self, ctx, extension_name: str):
async def disable_extension(
self, ctx: commands.Context, extension_name: str
) -> None:
"""Disables an extension for the guild.

This is a command and should be accessed via Discord.

parameters:
ctx (discord.ext.Context): the context object for the message
ctx (commands.Context): the context object for the message
extension_name (str): the extension subname to disable
"""
if not (
Expand Down Expand Up @@ -210,7 +214,7 @@ async def disable_extension(self, ctx, extension_name: str):
brief="Resets current guild config",
description="Resets config to default for the current guild",
)
async def reset_config(self, ctx: commands.Context):
async def reset_config(self, ctx: commands.Context) -> None:
"""A function to reset the current guild config to stock

Args:
Expand Down
6 changes: 4 additions & 2 deletions techsupport_bot/commands/correct.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
from discord.ext import commands


async def setup(bot):
async def setup(bot) -> None:
"""Method to add correct to the config."""
await bot.add_cog(Corrector(bot=bot))

Expand Down Expand Up @@ -77,6 +77,8 @@ def prepare_message(
description="Replaces the most recent text with your text",
usage="[to_replace] [replacement]",
)
async def correct(self, ctx, to_replace: str, replacement: str):
async def correct(
self, ctx: commands.Context, to_replace: str, replacement: str
) -> None:
"""Method for the correct command for the discord bot."""
await self.correct_command(ctx, to_replace, replacement)
Loading