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
7 changes: 5 additions & 2 deletions techsupport_bot/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
import asyncio
import datetime
import glob
import io
import json
import os
import threading
Expand Down Expand Up @@ -383,7 +384,7 @@ async def get_log_channel_from_guild(

Args:
guild (discord.Guild): the guild object to reference
key (string): the key to use when looking up the channel
key (str): the key to use when looking up the channel
"""
if not guild:
return None
Expand Down Expand Up @@ -675,7 +676,9 @@ def get_command_extension_name(self, command: commands.Command) -> str:
extension_name = command.module.split(".")[1]
return extension_name

async def register_file_extension(self, extension_name: str, fp) -> None:
async def register_file_extension(
self, extension_name: str, fp: io.BufferedIOBase
) -> None:
"""Offers an interface for loading an extension from an external source.

This saves the external file data to the OS, without any validation.
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 @@ -20,7 +20,7 @@ class Animals(cogs.BaseCog):

@auxiliary.with_typing
@commands.command(name="cat", brief="Gets a cat", description="Gets a cat")
async def cat(self, ctx: commands.context) -> None:
async def cat(self, ctx: commands.Context) -> None:
"""Prints a cat to discord

Args:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/burn.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Burn(cogs.BaseCog):
]

async def handle_burn(
self, ctx, user: discord.Member, message: discord.Message
self, ctx: commands.Context, user: discord.Member, message: discord.Message
) -> None:
"""The core logic to handle the burn command

Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/commandcontrol.py
Original file line number Diff line number Diff line change
Expand Up @@ -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):
async def command_group(self, ctx: commands.Context):
"""The bare .command command. This does nothing but generate the help message

Args:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/conch.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ def format_question(self, question: str) -> str:
question += "?"
return question

async def conch_command(self, ctx, question: str = "") -> None:
async def conch_command(self, ctx: commands.Context, question: str = "") -> None:
"""Method for the core logic of the conch command

Args:
Expand Down
4 changes: 3 additions & 1 deletion techsupport_bot/commands/correct.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,9 @@ async def setup(bot):
class Corrector(cogs.BaseCog):
"""Class for the correct command for the discord bot."""

async def correct_command(self, ctx, to_replace: str, replacement: str) -> None:
async def correct_command(
self, ctx: commands.Context, to_replace: str, replacement: str
) -> None:
"""This is the main processing for the correct command

Args:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/echo.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ class MessageEcho(cogs.BaseCog):
@commands.group(
brief="Executes an echo bot command", description="Executes an echo bot command"
)
async def echo(self, ctx):
async def echo(self, ctx: commands.Context):
"""The bare .echo command. This does nothing but generate the help message

Args:
Expand Down
3 changes: 2 additions & 1 deletion techsupport_bot/commands/embed.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,7 @@
"""

import discord
import munch
from core import auxiliary, cogs, extensionconfig
from discord.ext import commands

Expand Down Expand Up @@ -152,7 +153,7 @@ async def embed(self, ctx: commands.Context, *, keep_option: str = None):
"I couldn't generate all of your embeds, so I gave you a blank slate",
)

async def process_request(self, request_body) -> list[discord.Embed]:
async def process_request(self, request_body: munch.Munch) -> list[discord.Embed]:
"""Returns a list of discord.Embed objects from a request_body

Args:
Expand Down
10 changes: 7 additions & 3 deletions techsupport_bot/commands/emoji.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Emojis(cogs.BaseCog):
KEY_MAP = {"?": "question", "!": "exclamation"}

@classmethod
def emoji_from_char(cls, char):
def emoji_from_char(cls, char: str):
"""Gets an unicode emoji from a character

Args:
Expand Down Expand Up @@ -55,7 +55,7 @@ def check_if_all_unique(self, string: str):
return len(set(string.lower())) == len(string.lower())

@classmethod
def generate_emoji_string(cls, string, only_emoji=False):
def generate_emoji_string(cls, string: str, only_emoji: bool = False):
"""This takes a string and returns a string or list of emojis

Args:
Expand All @@ -81,7 +81,11 @@ def generate_emoji_string(cls, string, only_emoji=False):
return emoji_list

async def emoji_commands(
self, ctx, message: str, add_reactions: bool, react_user: discord.Member = None
self,
ctx: commands.Context,
message: str,
add_reactions: bool,
react_user: discord.Member = None,
):
"""A method to handle the core of both emoji message and reaction

Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/extension.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@ class ExtensionControl(cogs.BaseCog):
brief="Executes an extension bot command",
description="Executes an extension bot command",
)
async def extension_group(self, ctx):
async def extension_group(self, ctx: commands.Context):
"""The bare .extension command. This does nothing but generate the help message

Args:
Expand Down
8 changes: 4 additions & 4 deletions techsupport_bot/commands/factoids.py
Original file line number Diff line number Diff line change
Expand Up @@ -189,11 +189,11 @@ async def preconfig(self):
await self.kickoff_jobs()

# -- DB calls --
async def delete_factoid_call(self, factoid, guild: str):
async def delete_factoid_call(self, factoid: bot.models.Factoid, guild: str):
"""Calls the db to delete a factoid

Args:
factoid (Factoid): The factoid to delete
factoid (bot.models.Factoid): The factoid to delete
guild (str): The guild ID for cache handling
"""
# Removes the `factoid all` cache since it has become outdated
Expand Down Expand Up @@ -843,11 +843,11 @@ async def kickoff_jobs(self):
task = asyncio.create_task(self.cronjob(job))
task = self.running_jobs[job_id]["task"] = task

async def cronjob(self, job, ctx: commands.Context = None):
async def cronjob(self, job: bot.models.FactoidJob, ctx: commands.Context = None):
"""Run a cron job for a factoid

Args:
job (FactoidJob): The job to start
job (bot.models.FactoidJob): The job to start
ctx (commands.Context): The context, used for logging
"""
job_id = job.job_id
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/hello.py
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,7 @@ async def setup(bot):
class Greeter(cogs.BaseCog):
"""Class for the greeter command."""

async def hello_command(self, ctx) -> None:
async def hello_command(self, ctx: commands.Context) -> None:
"""A simple function to add HEY reactions to the command invocation

Args:
Expand Down
4 changes: 2 additions & 2 deletions techsupport_bot/commands/htd.py
Original file line number Diff line number Diff line change
Expand Up @@ -131,7 +131,7 @@ def perform_op_on_list(self, equation_list: list) -> int:
" (hex)\n0b (binary) \nNo prefix (assumed decimal)"
),
)
async def htd(self, ctx, *, val_to_convert):
async def htd(self, ctx: commands.Context, *, val_to_convert: str):
"""This discord command for .htd

Args:
Expand Down Expand Up @@ -290,7 +290,7 @@ async def htd_command(self, ctx: commands.Context, val_to_convert: str) -> None:
"""The main logic for the htd command

Args:
ctx (command.Context): The context in which the command was run it
ctx (commands.Context): The context in which the command was run it
val_to_convert (str): The raw user input
"""
val_to_convert = self.clean_input(val_to_convert)
Expand Down
5 changes: 3 additions & 2 deletions techsupport_bot/commands/relay.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from typing import Dict, List, Union

import discord
import irc.client
import munch
import ui
from bidict import bidict
Expand Down Expand Up @@ -126,7 +127,7 @@ async def handle_factoid(
brief="Executes an irc command",
description="Executes an irc command",
)
async def irc(self, ctx: commands.Context) -> None:
async def irc_base(self, ctx: commands.Context) -> None:
"""The base set of IRC commands

Args:
Expand Down Expand Up @@ -495,7 +496,7 @@ async def on_reaction_add(
reaction=reaction, user=user, channel=self.mapping[str(channel.id)]
)

async def handle_dm_from_irc(self, message: str, event) -> None:
async def handle_dm_from_irc(self, message: str, event: irc.client.Event) -> None:
"""Sends a DM to the owner of the bot based on a message from IRC

Args:
Expand Down
4 changes: 2 additions & 2 deletions techsupport_bot/commands/role.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ async def setup(bot: bot.TechSupportBot):
"""Adding config and the cog to the bot

Args:
bot (commands.Bot): The bot object
bot (bot.TechSupportBot): The bot object
"""
config = extensionconfig.ExtensionConfig()
config.add(
Expand Down Expand Up @@ -215,7 +215,7 @@ def check_permissions(
Args:
user (discord.User): The user executing the command
guild (discord.Guild): The guild the command was run in
roles (list): A list of the roles allowed to execute
roles (list[str]): A list of the roles allowed to execute

Returns:
bool: True if can execute, false if cannot
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/roll.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ class Roller(cogs.BaseCog):
description="Rolls a random number in a given range",
usage="[minimum] [maximum] (defaults to 1-100)",
)
async def roll(self, ctx, min: int = 1, max: int = 100):
async def roll(self, ctx: commands.Context, min: int = 1, max: int = 100):
"""The function that is called when .roll is run on discord

Args:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/set.py
Original file line number Diff line number Diff line change
Expand Up @@ -29,7 +29,7 @@ class Setter(cogs.BaseCog):
brief="Executes a `set X` bot command",
description="Executes a `set X` bot command",
)
async def set_group(self, ctx):
async def set_group(self, ctx: commands.Context):
"""The bare .set command. This does nothing but generate the help message

Args:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/commands/sync.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ class AppCommandSync(cogs.BaseCog):
description="Syncs slash commands",
usage="",
)
async def sync_slash_commands(self, ctx):
async def sync_slash_commands(self, ctx: commands.Context):
"""A simple command to manually sync slash commands

Args:
Expand Down
6 changes: 3 additions & 3 deletions techsupport_bot/core/auxiliary.py
Original file line number Diff line number Diff line change
Expand Up @@ -51,7 +51,7 @@ async def search_channel_for_message(
"""Searches the last 50 messages in a channel based on given conditions

Args:
channel (discord.TextChannel): The channel to search in. This is required
channel (discord.abc.Messageable): The channel to search in. This is required
prefix (str, optional): A prefix you want to exclude from the search. Defaults to None.
member_to_match (discord.Member, optional): The member that the
message found must be from. Defaults to None.
Expand Down Expand Up @@ -147,7 +147,7 @@ async def send_deny_embed(
Args:
message (str): The reason for deny
channel (discord.abc.Messageable): The channel to send the deny embed to
author (discord.Member, optional): The author of the message.
author (discord.Member | None, optional): The author of the message.
If this is provided, the author will be mentioned

Returns:
Expand Down Expand Up @@ -185,7 +185,7 @@ async def send_confirm_embed(
Args:
message (str): The reason for confirm
channel (discord.abc.Messageable): The channel to send the confirm embed to
author (discord.Member, optional): The author of the message.
author (discord.Member | None, optional): The author of the message.
If this is provided, the author will be mentioned

Returns:
Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/tests/helpers/channel.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class MockChannel:
def __init__(self, history=None):
self.message_history = history

async def history(self, limit) -> AsyncGenerator[str, None]:
async def history(self, limit: int) -> AsyncGenerator[str, None]:
"""Replication of the async history method
As history is not expected to be massive, this just yields every message

Expand Down
2 changes: 1 addition & 1 deletion techsupport_bot/tests/helpers/message.py
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@ def __init__(self, content=None, author=None, attachments=None, reactions=None):
self.attachments = attachments
self.reactions = reactions

async def add_reaction(self, reaction):
async def add_reaction(self, reaction: list):
"""Replication of the adding a reaction
Adding reactions to a previous message

Expand Down
3 changes: 2 additions & 1 deletion techsupport_bot/ui/pagination.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ async def send(
author (discord.Member): The author of the pages command
data (list[Union[str, discord.Embed]]): A list of pages in order
with [0] being the first page
interaction (discord.Interaction): The interaction this should followup with (Optional)
interaction (discord.Interaction | None): The interaction this
should followup with (Optional)
"""
self.author = author
self.data = data
Expand Down