diff options
35 files changed, 136 insertions, 132 deletions
diff --git a/bot/exts/evergreen/8bitify.py b/bot/exts/evergreen/8bitify.py index 7eb4d313..09a3eb5c 100644 --- a/bot/exts/evergreen/8bitify.py +++ b/bot/exts/evergreen/8bitify.py @@ -4,11 +4,13 @@ import discord from PIL import Image from discord.ext import commands +from bot.bot import Bot + class EightBitify(commands.Cog): """Make your avatar 8bit!""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, bot: Bot) -> None: self.bot = bot @staticmethod @@ -50,6 +52,6 @@ class EightBitify(commands.Cog): await ctx.send(file=file, embed=embed) -def setup(bot: commands.Bot) -> None: - """Cog load.""" +def setup(bot: Bot) -> None: + """Cog the EightBitify load.""" bot.add_cog(EightBitify(bot)) diff --git a/bot/exts/evergreen/battleship.py b/bot/exts/evergreen/battleship.py index 1681434f..813f998e 100644 --- a/bot/exts/evergreen/battleship.py +++ b/bot/exts/evergreen/battleship.py @@ -9,6 +9,7 @@ from functools import partial import discord from discord.ext import commands +from bot.bot import Bot from bot.constants import Colours log = logging.getLogger(__name__) @@ -95,7 +96,7 @@ class Game: def __init__( self, - bot: commands.Bot, + bot: Bot, channel: discord.TextChannel, player1: discord.Member, player2: discord.Member @@ -237,7 +238,7 @@ class Game: square = None turn_message = await self.turn.user.send( "It's your turn! Type the square you want to fire at. Format it like this: A1\n" - "Type `surrender` to give up" + "Type `surrender` to give up." ) await self.next.user.send("Their turn", delete_after=3.0) while True: @@ -321,7 +322,7 @@ class Game: class Battleship(commands.Cog): """Play the classic game Battleship!""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, bot: Bot) -> None: self.bot = bot self.games: typing.List[Game] = [] self.waiting: typing.List[discord.Member] = [] @@ -381,7 +382,7 @@ class Battleship(commands.Cog): return await ctx.send("You're already playing a game!") if ctx.author in self.waiting: - return await ctx.send("You've already sent out a request for a player 2") + return await ctx.send("You've already sent out a request for a player 2.") announcement = await ctx.send( "**Battleship**: A new game is about to start!\n" @@ -425,7 +426,7 @@ class Battleship(commands.Cog): self.games.remove(game) except Exception: # End the game in the event of an unforseen error so the players aren't stuck in a game - await ctx.send(f"{ctx.author.mention} {user.mention} An error occurred. Game failed") + await ctx.send(f"{ctx.author.mention} {user.mention} An error occurred. Game failed.") self.games.remove(game) raise @@ -438,6 +439,6 @@ class Battleship(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Cog load.""" +def setup(bot: Bot) -> None: + """Load the Battleship cog""" bot.add_cog(Battleship(bot)) diff --git a/bot/exts/evergreen/bookmark.py b/bot/exts/evergreen/bookmark.py index 5fa05d2e..6a272784 100644 --- a/bot/exts/evergreen/bookmark.py +++ b/bot/exts/evergreen/bookmark.py @@ -4,6 +4,7 @@ import random import discord from discord.ext import commands +from bot.bot import Bot from bot.constants import Colours, ERROR_REPLIES, Emojis, Icons from bot.utils.converters import WrappedMessageConverter @@ -13,9 +14,6 @@ log = logging.getLogger(__name__) class Bookmark(commands.Cog): """Creates personal bookmarks by relaying a message link to the user's DMs.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @commands.command(name="bookmark", aliases=("bm", "pin")) async def bookmark( self, @@ -28,7 +26,7 @@ class Bookmark(commands.Cog): # Prevent users from bookmarking a message in a channel they don't have access to permissions = ctx.author.permissions_in(target_message.channel) if not permissions.read_messages: - log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions") + log.info(f"{ctx.author} tried to bookmark a message in #{target_message.channel} but has no permissions.") embed = discord.Embed( title=random.choice(ERROR_REPLIES), color=Colours.soft_red, @@ -51,7 +49,7 @@ class Bookmark(commands.Cog): except discord.Forbidden: error_embed = discord.Embed( title=random.choice(ERROR_REPLIES), - description=f"{ctx.author.mention}, please enable your DMs to receive the bookmark", + description=f"{ctx.author.mention}, please enable your DMs to receive the bookmark.", colour=Colours.soft_red ) await ctx.send(embed=error_embed) @@ -60,6 +58,6 @@ class Bookmark(commands.Cog): await ctx.message.add_reaction(Emojis.envelope) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the Bookmark cog.""" bot.add_cog(Bookmark(bot)) diff --git a/bot/exts/evergreen/cheatsheet.py b/bot/exts/evergreen/cheatsheet.py index 3fe709d5..57c6d0b0 100644 --- a/bot/exts/evergreen/cheatsheet.py +++ b/bot/exts/evergreen/cheatsheet.py @@ -8,6 +8,7 @@ from discord.ext import commands from discord.ext.commands import BucketType, Context from bot import constants +from bot.bot import Bot from bot.constants import Categories, Channels, Colours, ERROR_REPLIES from bot.utils.decorators import whitelist_override @@ -33,7 +34,7 @@ HEADERS = {'User-Agent': 'curl/7.68.0'} class CheatSheet(commands.Cog): """Commands that sends a result of a cht.sh search in code blocks.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot @staticmethod @@ -102,6 +103,6 @@ class CheatSheet(commands.Cog): await ctx.send(content=description) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the CheatSheet cog.""" bot.add_cog(CheatSheet(bot)) diff --git a/bot/exts/evergreen/connect_four.py b/bot/exts/evergreen/connect_four.py index 7e3ec42b..df2a913a 100644 --- a/bot/exts/evergreen/connect_four.py +++ b/bot/exts/evergreen/connect_four.py @@ -8,6 +8,7 @@ import emojis from discord.ext import commands from discord.ext.commands import guild_only +from bot.bot import Bot from bot.constants import Emojis NUMBERS = list(Emojis.number_emojis.values()) @@ -22,7 +23,7 @@ class Game: def __init__( self, - bot: commands.Bot, + bot: Bot, channel: discord.TextChannel, player1: discord.Member, player2: typing.Optional[discord.Member], @@ -180,7 +181,7 @@ class Game: class AI: """The Computer Player for Single-Player games.""" - def __init__(self, bot: commands.Bot, game: Game) -> None: + def __init__(self, bot: Bot, game: Game) -> None: self.game = game self.mention = bot.user.mention @@ -255,7 +256,7 @@ class AI: class ConnectFour(commands.Cog): """Connect Four. The Classic Vertical Four-in-a-row Game!""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, bot: Bot) -> None: self.bot = bot self.games: typing.List[Game] = [] self.waiting: typing.List[discord.Member] = [] @@ -354,7 +355,7 @@ class ConnectFour(commands.Cog): self.games.remove(game) except Exception: # End the game in the event of an unforeseen error so the players aren't stuck in a game - await ctx.send(f"{ctx.author.mention} {user.mention if user else ''} An error occurred. Game failed") + await ctx.send(f"{ctx.author.mention} {user.mention if user else ''} An error occurred. Game failed.") if game in self.games: self.games.remove(game) raise @@ -445,6 +446,6 @@ class ConnectFour(commands.Cog): await self._play_game(ctx, None, board_size, str(emoji1), str(emoji2)) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load ConnectFour Cog.""" bot.add_cog(ConnectFour(bot)) diff --git a/bot/exts/evergreen/conversationstarters.py b/bot/exts/evergreen/conversationstarters.py index e7058961..54fea0b3 100644 --- a/bot/exts/evergreen/conversationstarters.py +++ b/bot/exts/evergreen/conversationstarters.py @@ -4,6 +4,7 @@ import yaml from discord import Color, Embed from discord.ext import commands +from bot.bot import Bot from bot.constants import WHITELISTED_CHANNELS from bot.utils.decorators import whitelist_override from bot.utils.randomization import RandomCycle @@ -34,9 +35,6 @@ TOPICS = { class ConvoStarters(commands.Cog): """Evergreen conversation topics.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @commands.command() @whitelist_override(channels=ALL_ALLOWED_CHANNELS) async def topic(self, ctx: commands.Context) -> None: @@ -66,6 +64,6 @@ class ConvoStarters(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Conversation starters Cog load.""" +def setup(bot: Bot) -> None: + """Load the ConvoStarters cog.""" bot.add_cog(ConvoStarters(bot)) diff --git a/bot/exts/evergreen/emoji.py b/bot/exts/evergreen/emoji.py index fa3044e3..8e540712 100644 --- a/bot/exts/evergreen/emoji.py +++ b/bot/exts/evergreen/emoji.py @@ -8,6 +8,7 @@ from typing import List, Optional, Tuple from discord import Color, Embed, Emoji from discord.ext import commands +from bot.bot import Bot from bot.constants import Colours, ERROR_REPLIES from bot.utils.extensions import invoke_help_command from bot.utils.pagination import LinePaginator @@ -19,9 +20,6 @@ log = logging.getLogger(__name__) class Emojis(commands.Cog): """A collection of commands related to emojis in the server.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @staticmethod def embed_builder(emoji: dict) -> Tuple[Embed, List[str]]: """Generates an embed with the emoji names and count.""" @@ -86,7 +84,7 @@ class Emojis(commands.Cog): if not ctx.guild.emojis: await ctx.send("No emojis found.") return - log.trace(f"Emoji Category {'' if category_query else 'not '}provided by the user") + log.trace(f"Emoji Category {'' if category_query else 'not '}provided by the user.") for emoji in ctx.guild.emojis: emoji_category = emoji.name.split("_")[0] @@ -120,6 +118,6 @@ class Emojis(commands.Cog): await ctx.send(embed=emoji_information) -def setup(bot: commands.Bot) -> None: - """Add the Emojis cog into the bot.""" +def setup(bot: Bot) -> None: + """Load the Emojis cog.""" bot.add_cog(Emojis(bot)) diff --git a/bot/exts/evergreen/error_handler.py b/bot/exts/evergreen/error_handler.py index 8db49748..dabd0ab5 100644 --- a/bot/exts/evergreen/error_handler.py +++ b/bot/exts/evergreen/error_handler.py @@ -7,6 +7,7 @@ from discord import Embed, Message from discord.ext import commands from sentry_sdk import push_scope +from bot.bot import Bot from bot.constants import Channels, Colours, ERROR_REPLIES, NEGATIVE_REPLIES from bot.utils.decorators import InChannelCheckFailure, InMonthCheckFailure from bot.utils.exceptions import UserNotPlayingError @@ -17,9 +18,6 @@ log = logging.getLogger(__name__) class CommandErrorHandler(commands.Cog): """A error handler for the PythonDiscord server.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @staticmethod def revert_cooldown_counter(command: commands.Command, message: Message) -> None: """Undoes the last cooldown counter for user-error cases.""" @@ -135,6 +133,6 @@ class CommandErrorHandler(commands.Cog): log.exception(f"Unhandled command error: {str(error)}", exc_info=error) -def setup(bot: commands.Bot) -> None: - """Error handler Cog load.""" +def setup(bot: Bot) -> None: + """Load the ErrorHandler cog.""" bot.add_cog(CommandErrorHandler(bot)) diff --git a/bot/exts/evergreen/fun.py b/bot/exts/evergreen/fun.py index 101725da..c7b0d7d9 100644 --- a/bot/exts/evergreen/fun.py +++ b/bot/exts/evergreen/fun.py @@ -7,9 +7,10 @@ from typing import Callable, Iterable, Tuple, Union from discord import Embed, Message from discord.ext import commands -from discord.ext.commands import BadArgument, Bot, Cog, Context, MessageConverter, clean_content +from discord.ext.commands import BadArgument, Cog, Context, MessageConverter, clean_content from bot import utils +from bot.bot import Bot from bot.constants import Client, Colours, Emojis log = logging.getLogger(__name__) @@ -239,6 +240,6 @@ class Fun(Cog): return Embed.from_dict(embed_dict) -def setup(bot: commands.Bot) -> None: - """Fun Cog load.""" +def setup(bot: Bot) -> None: + """Load the Fun cog.""" bot.add_cog(Fun(bot)) diff --git a/bot/exts/evergreen/game.py b/bot/exts/evergreen/game.py index 068d3f68..24872e76 100644 --- a/bot/exts/evergreen/game.py +++ b/bot/exts/evergreen/game.py @@ -471,7 +471,7 @@ class Games(Cog): def setup(bot: Bot) -> None: - """Add/Load Games cog.""" + """Load the Games cog.""" # Check does IGDB API key exist, if not, log warning and don't load cog if not Tokens.igdb_client_id: logger.warning("No IGDB client ID. Not loading Games cog.") diff --git a/bot/exts/evergreen/githubinfo.py b/bot/exts/evergreen/githubinfo.py index c8a6b3f7..fd100a7c 100644 --- a/bot/exts/evergreen/githubinfo.py +++ b/bot/exts/evergreen/githubinfo.py @@ -7,6 +7,7 @@ import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType +from bot.bot import Bot from bot.constants import Colours, NEGATIVE_REPLIES from bot.exts.utils.extensions import invoke_help_command @@ -18,7 +19,7 @@ GITHUB_API_URL = "https://api.github.com" class GithubInfo(commands.Cog): """Fetches info from GitHub.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot async def fetch_data(self, url: str) -> dict: @@ -95,7 +96,7 @@ class GithubInfo(commands.Cog): embed.add_field( name=f"Organization{'s' if len(orgs)!=1 else ''}", - value=orgs_to_add if orgs else "No organizations" + value=orgs_to_add if orgs else "No organizations." ) embed.add_field(name="Website", value=blog) @@ -170,6 +171,6 @@ class GithubInfo(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Adding the cog to the bot.""" +def setup(bot: Bot) -> None: + """Load the GithubInfo cog.""" bot.add_cog(GithubInfo(bot)) diff --git a/bot/exts/evergreen/issues.py b/bot/exts/evergreen/issues.py index a0316080..d7ee99c0 100644 --- a/bot/exts/evergreen/issues.py +++ b/bot/exts/evergreen/issues.py @@ -7,6 +7,7 @@ from dataclasses import dataclass import discord from discord.ext import commands +from bot.bot import Bot from bot.constants import ( Categories, Channels, @@ -91,7 +92,7 @@ class IssueState: class Issues(commands.Cog): """Cog that allows users to retrieve issues from GitHub.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot self.repos = [] @@ -269,6 +270,6 @@ class Issues(commands.Cog): await message.channel.send(embed=resp) -def setup(bot: commands.Bot) -> None: - """Cog Retrieves Issues From Github.""" +def setup(bot: Bot) -> None: + """Load the Issues cog.""" bot.add_cog(Issues(bot)) diff --git a/bot/exts/evergreen/latex.py b/bot/exts/evergreen/latex.py index c4a8597c..3a93907a 100644 --- a/bot/exts/evergreen/latex.py +++ b/bot/exts/evergreen/latex.py @@ -9,6 +9,8 @@ import discord import matplotlib.pyplot as plt from discord.ext import commands +from bot.bot import Bot + # configure fonts and colors for matplotlib plt.rcParams.update( { @@ -89,6 +91,6 @@ class Latex(commands.Cog): await ctx.send(file=discord.File(image, "latex.png")) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the Latex Cog.""" bot.add_cog(Latex(bot)) diff --git a/bot/exts/evergreen/magic_8ball.py b/bot/exts/evergreen/magic_8ball.py index f974e487..708aa6d2 100644 --- a/bot/exts/evergreen/magic_8ball.py +++ b/bot/exts/evergreen/magic_8ball.py @@ -5,14 +5,15 @@ from pathlib import Path from discord.ext import commands +from bot.bot import Bot + log = logging.getLogger(__name__) class Magic8ball(commands.Cog): """A Magic 8ball command to respond to a user's question.""" - def __init__(self, bot: commands.Bot): - self.bot = bot + def __init__(self, _bot: Bot): with open(Path("bot/resources/evergreen/magic8ball.json"), "r", encoding="utf8") as file: self.answers = json.load(file) @@ -26,6 +27,6 @@ class Magic8ball(commands.Cog): await ctx.send("Usage: .8ball <question> (minimum length of 3 eg: `will I win?`)") -def setup(bot: commands.Bot) -> None: - """Magic 8ball Cog load.""" +def setup(bot: Bot) -> None: + """Load the Magic8Ball cog.""" bot.add_cog(Magic8ball(bot)) diff --git a/bot/exts/evergreen/minesweeper.py b/bot/exts/evergreen/minesweeper.py index 3031debc..d0cc28c5 100644 --- a/bot/exts/evergreen/minesweeper.py +++ b/bot/exts/evergreen/minesweeper.py @@ -6,6 +6,7 @@ from random import randint, random import discord from discord.ext import commands +from bot.bot import Bot from bot.constants import Client from bot.utils.exceptions import UserNotPlayingError from bot.utils.extensions import invoke_help_command @@ -37,7 +38,7 @@ class CoordinateConverter(commands.Converter): async def convert(self, ctx: commands.Context, coordinate: str) -> typing.Tuple[int, int]: """Take in a coordinate string and turn it into an (x, y) tuple.""" if not 2 <= len(coordinate) <= 3: - raise commands.BadArgument('Invalid co-ordinate provided') + raise commands.BadArgument('Invalid co-ordinate provided.') coordinate = coordinate.lower() if coordinate[0].isalpha(): @@ -78,7 +79,7 @@ GamesDict = typing.Dict[int, Game] class Minesweeper(commands.Cog): """Play a game of Minesweeper.""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, _bot: Bot) -> None: self.games: GamesDict = {} # Store the currently running games @commands.group(name='minesweeper', aliases=('ms',), invoke_without_command=True) @@ -148,7 +149,7 @@ class Minesweeper(commands.Cog): f"Close the game with `{Client.prefix}ms end`\n" ) except discord.errors.Forbidden: - log.debug(f"{ctx.author.name} ({ctx.author.id}) has disabled DMs from server members") + log.debug(f"{ctx.author.name} ({ctx.author.id}) has disabled DMs from server members.") await ctx.send(f":x: {ctx.author.mention}, please enable DMs to play minesweeper.") return @@ -158,7 +159,7 @@ class Minesweeper(commands.Cog): dm_msg = await ctx.author.send(f"Here's your board!\n{self.format_for_discord(revealed_board)}") if ctx.guild: - await ctx.send(f"{ctx.author.mention} is playing Minesweeper") + await ctx.send(f"{ctx.author.mention} is playing Minesweeper.") chat_msg = await ctx.send(f"Here's their board!\n{self.format_for_discord(revealed_board)}") else: chat_msg = None @@ -247,7 +248,7 @@ class Minesweeper(commands.Cog): """ Reveal one square. - return is True if the game ended, breaking the loop in `reveal_command` and deleting the game + return is True if the game ended, breaking the loop in `reveal_command` and deleting the game. """ revealed[y][x] = board[y][x] if board[y][x] == "bomb": @@ -285,13 +286,13 @@ class Minesweeper(commands.Cog): game = self.games[ctx.author.id] game.revealed = game.board await self.update_boards(ctx) - new_msg = f":no_entry: Game canceled :no_entry:\n{game.dm_msg.content}" + new_msg = f":no_entry: Game canceled. :no_entry:\n{game.dm_msg.content}" await game.dm_msg.edit(content=new_msg) if game.activated_on_server: await game.chat_msg.edit(content=new_msg) del self.games[ctx.author.id] -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the Minesweeper cog.""" bot.add_cog(Minesweeper(bot)) diff --git a/bot/exts/evergreen/movie.py b/bot/exts/evergreen/movie.py index b3bfe998..488e5142 100644 --- a/bot/exts/evergreen/movie.py +++ b/bot/exts/evergreen/movie.py @@ -6,8 +6,9 @@ from urllib.parse import urlencode from aiohttp import ClientSession from discord import Embed -from discord.ext.commands import Bot, Cog, Context, group +from discord.ext.commands import Cog, Context, group +from bot.bot import Bot from bot.constants import Tokens from bot.utils.extensions import invoke_help_command from bot.utils.pagination import ImagePaginator @@ -50,7 +51,6 @@ class Movie(Cog): """Movie Cog contains movies command that grab random movies from TMDB.""" def __init__(self, bot: Bot): - self.bot = bot self.http_session: ClientSession = bot.http_session @group(name='movies', aliases=['movie'], invoke_without_command=True) @@ -198,5 +198,5 @@ class Movie(Cog): def setup(bot: Bot) -> None: - """Load Movie Cog.""" + """Load the Movie Cog.""" bot.add_cog(Movie(bot)) diff --git a/bot/exts/evergreen/ping.py b/bot/exts/evergreen/ping.py index 97f8b34d..71152d15 100644 --- a/bot/exts/evergreen/ping.py +++ b/bot/exts/evergreen/ping.py @@ -1,13 +1,14 @@ from discord import Embed from discord.ext import commands +from bot.bot import Bot from bot.constants import Colours class Ping(commands.Cog): """Ping the bot to see its latency and state.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot @commands.command(name="ping") @@ -22,6 +23,6 @@ class Ping(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Cog load.""" +def setup(bot: Bot) -> None: + """Load the Ping cog.""" bot.add_cog(Ping(bot)) diff --git a/bot/exts/evergreen/pythonfacts.py b/bot/exts/evergreen/pythonfacts.py index 457c2fd3..73234d55 100644 --- a/bot/exts/evergreen/pythonfacts.py +++ b/bot/exts/evergreen/pythonfacts.py @@ -3,6 +3,7 @@ import itertools import discord from discord.ext import commands +from bot.bot import Bot from bot.constants import Colours with open('bot/resources/evergreen/python_facts.txt') as file: @@ -14,9 +15,6 @@ COLORS = itertools.cycle([Colours.python_blue, Colours.python_yellow]) class PythonFacts(commands.Cog): """Sends a random fun fact about Python.""" - def __init__(self, bot: commands.Bot) -> None: - self.bot = bot - @commands.command(name='pythonfact', aliases=['pyfact']) async def get_python_fact(self, ctx: commands.Context) -> None: """Sends a Random fun fact about Python.""" @@ -28,6 +26,6 @@ class PythonFacts(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Load PythonFacts Cog.""" +def setup(bot: Bot) -> None: + """Load the PythonFacts Cog.""" bot.add_cog(PythonFacts(bot)) diff --git a/bot/exts/evergreen/recommend_game.py b/bot/exts/evergreen/recommend_game.py index 5e262a5b..be329f44 100644 --- a/bot/exts/evergreen/recommend_game.py +++ b/bot/exts/evergreen/recommend_game.py @@ -6,6 +6,8 @@ from random import shuffle import discord from discord.ext import commands +from bot.bot import Bot + log = logging.getLogger(__name__) game_recs = [] @@ -20,7 +22,7 @@ shuffle(game_recs) class RecommendGame(commands.Cog): """Commands related to recommending games.""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, bot: Bot) -> None: self.bot = bot self.index = 0 @@ -45,6 +47,6 @@ class RecommendGame(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Loads the RecommendGame cog.""" bot.add_cog(RecommendGame(bot)) diff --git a/bot/exts/evergreen/reddit.py b/bot/exts/evergreen/reddit.py index 49127bea..ce22a864 100644 --- a/bot/exts/evergreen/reddit.py +++ b/bot/exts/evergreen/reddit.py @@ -5,6 +5,7 @@ import discord from discord.ext import commands from discord.ext.commands.cooldowns import BucketType +from bot.bot import Bot from bot.utils.pagination import ImagePaginator log = logging.getLogger(__name__) @@ -13,7 +14,7 @@ log = logging.getLogger(__name__) class Reddit(commands.Cog): """Fetches reddit posts.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot async def fetch(self, url: str) -> dict: @@ -123,6 +124,6 @@ class Reddit(commands.Cog): await ImagePaginator.paginate(pages, ctx, embed) -def setup(bot: commands.Bot) -> None: - """Load the Cog.""" +def setup(bot: Bot) -> None: + """Load the Reddit cog.""" bot.add_cog(Reddit(bot)) diff --git a/bot/exts/evergreen/snakes/_snakes_cog.py b/bot/exts/evergreen/snakes/_snakes_cog.py index 3732b559..70093912 100644 --- a/bot/exts/evergreen/snakes/_snakes_cog.py +++ b/bot/exts/evergreen/snakes/_snakes_cog.py @@ -423,7 +423,7 @@ class Snakes(Cog): try: reaction, user = await ctx.bot.wait_for("reaction_add", timeout=45.0, check=predicate) except asyncio.TimeoutError: - await ctx.channel.send(f"You took too long. The correct answer was **{options[answer]}**.") + await ctx.send(f"You took too long. The correct answer was **{options[answer]}**.") await message.clear_reactions() return @@ -720,7 +720,7 @@ class Snakes(Cog): snake_image = utils.snakes[snake_name] # Hatch the snake - message = await ctx.channel.send(embed=Embed(description="Hatching your snake :snake:...")) + message = await ctx.send(embed=Embed(description="Hatching your snake :snake:...")) await asyncio.sleep(1) for stage in utils.stages: @@ -737,7 +737,7 @@ class Snakes(Cog): text=" Owner: {0}#{1}".format(ctx.message.author.name, ctx.message.author.discriminator) ) - await ctx.channel.send(embed=my_snake_embed) + await ctx.send(embed=my_snake_embed) @snakes_group.command(name='movie') async def movie_command(self, ctx: Context) -> None: @@ -800,9 +800,9 @@ class Snakes(Cog): embed.set_thumbnail(url="https://i.imgur.com/LtFtC8H.png") try: - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) except HTTPException as err: - await ctx.channel.send("An error occurred while fetching a snake-related movie!") + await ctx.send("An error occurred while fetching a snake-related movie!") raise err from None @snakes_group.command(name='quiz') @@ -828,7 +828,7 @@ class Snakes(Cog): ) ) - quiz = await ctx.channel.send("", embed=embed) + quiz = await ctx.send("", embed=embed) await self._validate_answer(ctx, quiz, answer, options) @snakes_group.command(name='name', aliases=('name_gen',)) @@ -964,7 +964,7 @@ class Snakes(Cog): ) ) - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) @snakes_group.command(name='card') async def card_command(self, ctx: Context, *, name: Snake = None) -> None: @@ -1018,7 +1018,7 @@ class Snakes(Cog): color=SNAKE_COLOR, description=question ) - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) @snakes_group.command(name='snakify') async def snakify_command(self, ctx: Context, *, message: str = None) -> None: @@ -1059,7 +1059,7 @@ class Snakes(Cog): ) embed.description = f"*{self._snakify(message)}*" - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) @snakes_group.command(name='video', aliases=('get_video',)) async def video_command(self, ctx: Context, *, search: str = None) -> None: @@ -1095,7 +1095,7 @@ class Snakes(Cog): if len(data) > 0: num = random.randint(0, len(data) - 1) youtube_base_url = 'https://www.youtube.com/watch?v=' - await ctx.channel.send( + await ctx.send( content=f"{youtube_base_url}{data[num]['id']['videoId']}" ) else: @@ -1120,7 +1120,7 @@ class Snakes(Cog): # Embed and send embed.description = zen_quote - await ctx.channel.send( + await ctx.send( embed=embed ) # endregion diff --git a/bot/exts/evergreen/source.py b/bot/exts/evergreen/source.py index 45752bf9..14fd02f3 100644 --- a/bot/exts/evergreen/source.py +++ b/bot/exts/evergreen/source.py @@ -5,6 +5,7 @@ from typing import Optional, Tuple, Union from discord import Embed from discord.ext import commands +from bot.bot import Bot from bot.constants import Source SourceType = Union[commands.Command, commands.Cog, str, commands.ExtensionNotLoaded] @@ -31,9 +32,6 @@ class SourceConverter(commands.Converter): class BotSource(commands.Cog): """Displays information about the bot's source code.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @commands.command(name="source", aliases=("src",)) async def source_command(self, ctx: commands.Context, *, source_item: SourceConverter = None) -> None: """Display information and a GitHub link to the source code of a command, tag, or cog.""" @@ -104,6 +102,6 @@ class BotSource(commands.Cog): return embed -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the BotSource cog.""" bot.add_cog(BotSource(bot)) diff --git a/bot/exts/evergreen/space.py b/bot/exts/evergreen/space.py index 323ff659..ee9ad38c 100644 --- a/bot/exts/evergreen/space.py +++ b/bot/exts/evergreen/space.py @@ -39,7 +39,6 @@ class Space(Cog): """Space Cog contains commands, that show images, facts or other information about space.""" def __init__(self, bot: Bot): - self.bot = bot self.http_session = bot.http_session self.rovers = {} @@ -242,7 +241,7 @@ class Space(Cog): def setup(bot: Bot) -> None: - """Load Space Cog.""" + """Load the Space cog.""" if not Tokens.nasa: logger.warning("Can't find NASA API key. Not loading Space Cog.") return diff --git a/bot/exts/evergreen/speedrun.py b/bot/exts/evergreen/speedrun.py index 21aad5aa..bf6f2117 100644 --- a/bot/exts/evergreen/speedrun.py +++ b/bot/exts/evergreen/speedrun.py @@ -5,6 +5,8 @@ from random import choice from discord.ext import commands +from bot.bot import Bot + log = logging.getLogger(__name__) with Path('bot/resources/evergreen/speedrun_links.json').open(encoding="utf8") as file: LINKS = json.load(file) @@ -13,15 +15,12 @@ with Path('bot/resources/evergreen/speedrun_links.json').open(encoding="utf8") a class Speedrun(commands.Cog): """Commands about the video game speedrunning community.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @commands.command(name="speedrun") async def get_speedrun(self, ctx: commands.Context) -> None: """Sends a link to a video of a random speedrun.""" await ctx.send(choice(LINKS)) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the Speedrun cog.""" bot.add_cog(Speedrun(bot)) diff --git a/bot/exts/evergreen/status_codes.py b/bot/exts/evergreen/status_codes.py index 7c00fe20..635eef3d 100644 --- a/bot/exts/evergreen/status_codes.py +++ b/bot/exts/evergreen/status_codes.py @@ -3,6 +3,7 @@ from http import HTTPStatus import discord from discord.ext import commands +from bot.bot import Bot from bot.utils.extensions import invoke_help_command HTTP_DOG_URL = "https://httpstatusdogs.com/img/{code}.jpg" @@ -12,7 +13,7 @@ HTTP_CAT_URL = "https://http.cat/{code}.jpg" class HTTPStatusCodes(commands.Cog): """Commands that give HTTP statuses described and visualized by cats and dogs.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot @commands.group(name="http_status", aliases=("status", "httpstatus")) @@ -68,6 +69,6 @@ class HTTPStatusCodes(commands.Cog): await ctx.send(embed=embed) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the HTTPStatusCodes cog.""" bot.add_cog(HTTPStatusCodes(bot)) diff --git a/bot/exts/evergreen/tic_tac_toe.py b/bot/exts/evergreen/tic_tac_toe.py index 6e21528e..1fef427a 100644 --- a/bot/exts/evergreen/tic_tac_toe.py +++ b/bot/exts/evergreen/tic_tac_toe.py @@ -246,8 +246,7 @@ def is_requester_free() -> t.Callable: class TicTacToe(Cog): """TicTacToe cog contains tic-tac-toe game commands.""" - def __init__(self, bot: Bot): - self.bot = bot + def __init__(self, _bot: Bot): self.games: t.List[Game] = [] @guild_only() @@ -323,5 +322,5 @@ class TicTacToe(Cog): def setup(bot: Bot) -> None: - """Load TicTacToe Cog.""" + """Load the TicTacToe cog.""" bot.add_cog(TicTacToe(bot)) diff --git a/bot/exts/evergreen/timed.py b/bot/exts/evergreen/timed.py index 5f177fd6..42a77346 100644 --- a/bot/exts/evergreen/timed.py +++ b/bot/exts/evergreen/timed.py @@ -4,6 +4,8 @@ from time import perf_counter from discord import Message from discord.ext import commands +from bot.bot import Bot + class TimedCommands(commands.Cog): """Time the command execution of a command.""" @@ -41,6 +43,6 @@ class TimedCommands(commands.Cog): await ctx.send(f"Command execution for `{new_ctx.command}` finished in {(t_end - t_start):.4f} seconds.") -def setup(bot: commands.Bot) -> None: - """Cog load.""" +def setup(bot: Bot) -> None: + """Load the Timed cog.""" bot.add_cog(TimedCommands(bot)) diff --git a/bot/exts/evergreen/trivia_quiz.py b/bot/exts/evergreen/trivia_quiz.py index fe692c2a..f40375a6 100644 --- a/bot/exts/evergreen/trivia_quiz.py +++ b/bot/exts/evergreen/trivia_quiz.py @@ -8,6 +8,7 @@ import discord from discord.ext import commands from fuzzywuzzy import fuzz +from bot.bot import Bot from bot.constants import Roles @@ -23,7 +24,7 @@ WRONG_ANS_RESPONSE = [ class TriviaQuiz(commands.Cog): """A cog for all quiz commands.""" - def __init__(self, bot: commands.Bot) -> None: + def __init__(self, bot: Bot) -> None: self.bot = bot self.questions = self.load_questions() self.game_status = {} # A variable to store the game status: either running or not running. @@ -299,6 +300,6 @@ class TriviaQuiz(commands.Cog): await channel.send(embed=embed) -def setup(bot: commands.Bot) -> None: - """Load the cog.""" +def setup(bot: Bot) -> None: + """Load the TriviaQuiz cog.""" bot.add_cog(TriviaQuiz(bot)) diff --git a/bot/exts/evergreen/uptime.py b/bot/exts/evergreen/uptime.py index a9ad9dfb..d2509e6f 100644 --- a/bot/exts/evergreen/uptime.py +++ b/bot/exts/evergreen/uptime.py @@ -5,6 +5,7 @@ from dateutil.relativedelta import relativedelta from discord.ext import commands from bot import start_time +from bot.bot import Bot log = logging.getLogger(__name__) @@ -12,9 +13,6 @@ log = logging.getLogger(__name__) class Uptime(commands.Cog): """A cog for posting the bot's uptime.""" - def __init__(self, bot: commands.Bot): - self.bot = bot - @commands.command(name="uptime") async def uptime(self, ctx: commands.Context) -> None: """Responds with the uptime of the bot.""" @@ -28,6 +26,6 @@ class Uptime(commands.Cog): await ctx.send(f"I started up {uptime_string}.") -def setup(bot: commands.Bot) -> None: - """Uptime Cog load.""" +def setup(bot: Bot) -> None: + """Load the Uptime cog.""" bot.add_cog(Uptime(bot)) diff --git a/bot/exts/evergreen/wikipedia.py b/bot/exts/evergreen/wikipedia.py index 068c4f43..e2172fc3 100644 --- a/bot/exts/evergreen/wikipedia.py +++ b/bot/exts/evergreen/wikipedia.py @@ -90,5 +90,5 @@ class WikipediaSearch(commands.Cog): def setup(bot: Bot) -> None: - """Wikipedia Cog load.""" + """Load the WikipediaSearch cog.""" bot.add_cog(WikipediaSearch(bot)) diff --git a/bot/exts/evergreen/wolfram.py b/bot/exts/evergreen/wolfram.py index 14ec1041..c57a8d7a 100644 --- a/bot/exts/evergreen/wolfram.py +++ b/bot/exts/evergreen/wolfram.py @@ -9,6 +9,7 @@ from discord import Embed from discord.ext import commands from discord.ext.commands import BucketType, Cog, Context, check, group +from bot.bot import Bot from bot.constants import Colours, STAFF_ROLES, Wolfram from bot.utils.pagination import ImagePaginator @@ -55,7 +56,7 @@ def custom_cooldown(*ignore: List[int]) -> Callable: """ Implement per-user and per-guild cooldowns for requests to the Wolfram API. - A list of roles may be provided to ignore the per-user cooldown + A list of roles may be provided to ignore the per-user cooldown. """ async def predicate(ctx: Context) -> bool: if ctx.invoked_with == 'help': @@ -102,7 +103,7 @@ def custom_cooldown(*ignore: List[int]) -> Callable: return check(predicate) -async def get_pod_pages(ctx: Context, bot: commands.Bot, query: str) -> Optional[List[Tuple]]: +async def get_pod_pages(ctx: Context, bot: Bot, query: str) -> Optional[List[Tuple]]: """Get the Wolfram API pod pages for the provided query.""" async with ctx.channel.typing(): url_str = parse.urlencode({ @@ -162,7 +163,7 @@ async def get_pod_pages(ctx: Context, bot: commands.Bot, query: str) -> Optional class Wolfram(Cog): """Commands for interacting with the Wolfram|Alpha API.""" - def __init__(self, bot: commands.Bot): + def __init__(self, bot: Bot): self.bot = bot @group(name="wolfram", aliases=("wolf", "wa"), invoke_without_command=True) @@ -188,11 +189,11 @@ class Wolfram(Cog): image_url = "attachment://image.png" if status == 501: - message = "Failed to get response" + message = "Failed to get response." footer = "" color = Colours.soft_red elif status == 400: - message = "No input found" + message = "No input found." footer = "" color = Colours.soft_red elif status == 403: @@ -268,12 +269,12 @@ class Wolfram(Cog): response_text = await response.text() if status == 501: - message = "Failed to get response" + message = "Failed to get response." color = Colours.soft_red elif status == 400: - message = "No input found" + message = "No input found." color = Colours.soft_red - elif response_text == "Error 1: Invalid appid": + elif response_text == "Error 1: Invalid appid.": message = "Wolfram API key is invalid or missing." color = Colours.soft_red else: @@ -283,6 +284,6 @@ class Wolfram(Cog): await send_embed(ctx, message, color) -def setup(bot: commands.Bot) -> None: +def setup(bot: Bot) -> None: """Load the Wolfram cog.""" bot.add_cog(Wolfram(bot)) diff --git a/bot/exts/evergreen/wonder_twins.py b/bot/exts/evergreen/wonder_twins.py index afc5346e..9fa2d7f8 100644 --- a/bot/exts/evergreen/wonder_twins.py +++ b/bot/exts/evergreen/wonder_twins.py @@ -2,15 +2,15 @@ import random from pathlib import Path import yaml -from discord.ext.commands import Bot, Cog, Context, command +from discord.ext.commands import Cog, Context, command + +from bot.bot import Bot class WonderTwins(Cog): """Cog for a Wonder Twins inspired command.""" - def __init__(self, bot: Bot): - self.bot = bot - + def __init__(self, _bot: Bot): with open(Path.cwd() / "bot" / "resources" / "evergreen" / "wonder_twins.yaml", "r", encoding="utf-8") as f: info = yaml.load(f, Loader=yaml.FullLoader) self.water_types = info["water_types"] diff --git a/bot/exts/evergreen/xkcd.py b/bot/exts/evergreen/xkcd.py index 1ff98ca2..ba9e46e0 100644 --- a/bot/exts/evergreen/xkcd.py +++ b/bot/exts/evergreen/xkcd.py @@ -87,5 +87,5 @@ class XKCD(Cog): def setup(bot: Bot) -> None: - """Loading the XKCD cog.""" + """Load the XKCD cog.""" bot.add_cog(XKCD(bot)) diff --git a/bot/exts/valentines/myvalenstate.py b/bot/exts/valentines/myvalenstate.py index 01801847..041af7af 100644 --- a/bot/exts/valentines/myvalenstate.py +++ b/bot/exts/valentines/myvalenstate.py @@ -78,7 +78,7 @@ class MyValenstate(commands.Cog): ) embed.add_field(name=embed_title, value=embed_text) embed.set_image(url=STATES[valenstate]["flag"]) - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: diff --git a/bot/exts/valentines/whoisvalentine.py b/bot/exts/valentines/whoisvalentine.py index 0ff9186c..ab6b1ca1 100644 --- a/bot/exts/valentines/whoisvalentine.py +++ b/bot/exts/valentines/whoisvalentine.py @@ -33,7 +33,7 @@ class ValentineFacts(commands.Cog): 'facial_reconstruction.jpg/1024px-Saint_Valentine_-_facial_reconstruction.jpg' ) - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) @commands.command() async def valentine_fact(self, ctx: commands.Context) -> None: @@ -44,7 +44,7 @@ class ValentineFacts(commands.Cog): color=Colours.pink ) - await ctx.channel.send(embed=embed) + await ctx.send(embed=embed) def setup(bot: commands.Bot) -> None: |