diff --git a/.flake8 b/.flake8 new file mode 100644 index 00000000..a8ca6316 --- /dev/null +++ b/.flake8 @@ -0,0 +1,4 @@ +[flake8] +max-line-length = 99 +select = E9,F7,F82 +extend-exclude=.venv/,.stubs/ diff --git a/.github/workflows/lint_python.yaml b/.github/workflows/lint_python.yaml deleted file mode 100644 index 18b1b4f4..00000000 --- a/.github/workflows/lint_python.yaml +++ /dev/null @@ -1,26 +0,0 @@ -name: Lint Python -on: - pull_request: - push: - repository_dispatch: - types: - - dispatched_test - -env: - ref: ${{ github.event.client_payload.ref || '' }} - -jobs: - lint_python: - name: Lint Python - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v2 - with: - ref: ${{ env.ref }} - - uses: actions/setup-python@v1 - with: - python_version: "3.8" - - run: "python -m pip install git+https://github.com/pycqa/pyflakes@1911c20#egg=pyflakes git+https://github.com/pycqa/pycodestyle@d219c68#egg=pycodestyle git+https://gitlab.com/pycqa/flake8@3.7.9#egg=flake8" - name: Install Flake8 - - run: "python -m flake8 . --count --select=E9,F7,F82 --show-source" - name: Flake8 Linting \ No newline at end of file diff --git a/.github/workflows/matchers/check-json.json b/.github/workflows/matchers/check-json.json new file mode 100644 index 00000000..0b49ade5 --- /dev/null +++ b/.github/workflows/matchers/check-json.json @@ -0,0 +1,17 @@ +{ + "__comment": "Credits to: https://github.com/home-assistant/core/blob/d32c364d7f9e138e0dd9363b34b3cb39f4afcd06/.github/workflows/matchers/check-json.json", + "problemMatcher": [ + { + "owner": "check-json", + "pattern": [ + { + "regexp": "^(.+):\\s(Failed to json decode\\s.+\\sline\\s(\\d+)\\scolumn\\s(\\d+).+)$", + "file": 1, + "message": 2, + "line": 3, + "column": 4 + } + ] + } + ] +} diff --git a/.github/workflows/matchers/check-toml.json b/.github/workflows/matchers/check-toml.json new file mode 100644 index 00000000..a1a9b0e6 --- /dev/null +++ b/.github/workflows/matchers/check-toml.json @@ -0,0 +1,16 @@ +{ + "problemMatcher": [ + { + "owner": "check-toml", + "pattern": [ + { + "regexp": "^(.+\\.toml):\\s(.+line\\s(\\d+)\\scolumn\\s(\\d+).+)$", + "file": 1, + "message": 2, + "line": 3, + "column": 4 + } + ] + } + ] +} diff --git a/.github/workflows/matchers/check-yaml.json b/.github/workflows/matchers/check-yaml.json new file mode 100644 index 00000000..ae5446a3 --- /dev/null +++ b/.github/workflows/matchers/check-yaml.json @@ -0,0 +1,19 @@ +{ + "problemMatcher": [ + { + "owner": "check-yaml", + "pattern": [ + { + "regexp": "^(.+)$", + "message": 1 + }, + { + "regexp": "^ in \"(.+\\.ya?ml)\", line (\\d+), column (\\d+)$", + "file": 1, + "line": 2, + "column": 3 + } + ] + } + ] +} diff --git a/.github/workflows/matchers/flake8.json b/.github/workflows/matchers/flake8.json new file mode 100644 index 00000000..4738c2ec --- /dev/null +++ b/.github/workflows/matchers/flake8.json @@ -0,0 +1,32 @@ +{ + "__comment": "Credits to: https://github.com/home-assistant/core/blob/d32c364d7f9e138e0dd9363b34b3cb39f4afcd06/.github/workflows/matchers/flake8.json", + "problemMatcher": [ + { + "owner": "flake8-error", + "severity": "error", + "pattern": [ + { + "regexp": "^(.+):(\\d+):(\\d+):\\s(([EF]\\d{3})\\s.*)$", + "file": 1, + "line": 2, + "column": 3, + "message": 4, + "code": 5 + } + ] + }, + { + "owner": "flake8-warning", + "severity": "warning", + "pattern": [ + { + "regexp": "^(.+):(\\d+):(\\d+):\\s(([CDNW]\\d{3})\\s.*)$", + "file": 1, + "line": 2, + "column": 3, + "message": 4 + } + ] + } + ] +} diff --git a/.github/workflows/run_precommit.yml b/.github/workflows/run_precommit.yml new file mode 100644 index 00000000..cedf97a0 --- /dev/null +++ b/.github/workflows/run_precommit.yml @@ -0,0 +1,41 @@ +name: Run pre-commit + +on: [push, pull_request] + +jobs: + run_precommit: + name: Run pre-commit + runs-on: ubuntu-latest + + steps: + # Checkout repository + - uses: actions/checkout@v3 + + # Setup Python and install pre-commit + - uses: actions/setup-python@v4 + with: + python-version: "3.8" + - name: Install pre-commit + run: | + pip install -U pre-commit + + # Load cached pre-commit environment + - name: set PY + run: echo "PY=$(python -VV | sha256sum | cut -d' ' -f1)" >> $GITHUB_ENV + - uses: actions/cache@v3 + with: + path: ~/.cache/pre-commit + key: pre-commit|${{ env.PY }}|${{ hashFiles('.pre-commit-config.yaml') }} + + # Register problem matchers + - name: Register problem matchers + run: | + echo "::add-matcher::.github/workflows/matchers/check-json.json" + echo "::add-matcher::.github/workflows/matchers/check-toml.json" + echo "::add-matcher::.github/workflows/matchers/check-yaml.json" + echo "::add-matcher::.github/workflows/matchers/flake8.json" + + # Run pre-commit + - name: Run pre-commit + run: | + pre-commit run --show-diff-on-failure --color=never --all-files --verbose diff --git a/.github/workflows/style.yaml b/.github/workflows/style.yaml deleted file mode 100644 index 3331f082..00000000 --- a/.github/workflows/style.yaml +++ /dev/null @@ -1,17 +0,0 @@ -name: Style formatting - -on: [push, pull_request] - -jobs: - mypy: - name: Style check with Black - runs-on: ubuntu-latest - steps: - - uses: actions/checkout@v1 - - uses: actions/setup-python@v1 - with: - python-version: "3.8" - - run: "python -m pip install black==19.10b0" - name: Install dependencies - - run: "make stylediff" - name: Run black \ No newline at end of file diff --git a/.pre-commit-config.yaml b/.pre-commit-config.yaml new file mode 100644 index 00000000..b1b76b36 --- /dev/null +++ b/.pre-commit-config.yaml @@ -0,0 +1,55 @@ +default_language_version: + python: python3.8 +exclude: ^.stubs/ +repos: + - repo: https://github.com/psf/black + rev: 'refs/tags/23.7.0:refs/tags/23.7.0' + hooks: + - id: black + - repo: https://github.com/Pierre-Sassoulas/black-disable-checker + rev: 'v1.1.3' + hooks: + - id: black-disable-checker + - repo: https://github.com/pycqa/flake8 + rev: '6.1.0' + hooks: + - id: flake8 + - repo: https://github.com/pre-commit/pre-commit-hooks + rev: v4.4.0 + hooks: + # `.gitattributes` should technically already handle this + # but autocrlf can result in local files keeping the CRLF + # which is problematic for codespell + - id: end-of-file-fixer + # normally you would want this but Neuro is not very consistent :P + # - id: mixed-line-ending + # args: + # - "--fix=lf" + + # Trailing whitespace is evil + - id: trailing-whitespace + + # Require literal syntax when initializing builtin types + - id: check-builtin-literals + + # Ensure that links to code on GitHub use the permalinks + - id: check-vcs-permalinks + + # Syntax validation + - id: check-ast + - id: check-json + - id: check-toml + # can be switched to yamllint when this issue gets resolved: + # https://github.com/adrienverge/yamllint/issues/238 + - id: check-yaml + + # JSON auto-formatter + - id: pretty-format-json + args: + - "--autofix" + - "--indent=4" + - "--no-sort-keys" + + # Checks for git-related issues + - id: check-case-conflict + - id: check-merge-conflict diff --git a/LICENSE b/LICENSE index 0ad9207c..6f4015b8 100644 --- a/LICENSE +++ b/LICENSE @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file +SOFTWARE. diff --git a/Makefile b/Makefile index b0419e6d..4c3a2cfe 100644 --- a/Makefile +++ b/Makefile @@ -2,8 +2,8 @@ PYTHON ?= python3.8 # Python Code Style reformat: - $(PYTHON) -m black -l 99 . + $(PYTHON) -m black . stylecheck: - $(PYTHON) -m black --check -l 99 . + $(PYTHON) -m black --check . stylediff: - $(PYTHON) -m black --check --diff -l 99 . \ No newline at end of file + $(PYTHON) -m black --check --diff . diff --git a/README.md b/README.md index 02805830..7c1f3fcd 100644 --- a/README.md +++ b/README.md @@ -78,4 +78,4 @@ For bugs, contact me at Neuro Assassin#4779 <@473541068378341376>. It would be [PrettyTable](https://pypi.org/project/PrettyTable/) and [FuzzyWuzzy](https://pypi.org/project/fuzzywuzzy/) are required for the listpermissions cog. -[Back to Table of Contents](#table-of-contents) \ No newline at end of file +[Back to Table of Contents](#table-of-contents) diff --git a/authgg/__init__.py b/authgg/__init__.py index cf187bc4..2b430e34 100644 --- a/authgg/__init__.py +++ b/authgg/__init__.py @@ -1,5 +1,5 @@ from .authgg import AuthGG -def setup(bot): - bot.add_cog(AuthGG(bot)) +async def setup(bot): + await bot.add_cog(AuthGG(bot)) diff --git a/authgg/authgg.py b/authgg/authgg.py index 63c700b6..360d8af5 100644 --- a/authgg/authgg.py +++ b/authgg/authgg.py @@ -24,7 +24,7 @@ from redbot.core.utils.predicates import MessagePredicate from redbot.core.utils.chat_formatting import humanize_list, inline -from redbot.core import commands, Config, checks +from redbot.core import commands, Config from typing import Optional import discord import asyncio @@ -50,7 +50,7 @@ async def authgg(self, ctx): @authgg.command() async def resethwid(self, ctx, apikey: str, *, name: Optional[str] = None): """Reset a user's HWID lock on auth.gg for the specified API key name. - + The API key name must be the friendly name provided by `[p]authgg keys add`.""" if not await self.bot.is_owner(ctx.author): roles = await self.conf.roles() @@ -135,7 +135,7 @@ async def changepw(self, ctx, apikey: str, username: str, password: str): "I was unable to delete your command message due to lack of perms. It is recommended to due so to prevent your user's password from getting leaked." ) - @checks.is_owner() + @commands.is_owner() @authgg.group() async def keys(self, ctx): """Manage API keys for auth.gg""" @@ -183,7 +183,7 @@ async def _keys_list(self, ctx): message = f"The following keys are currently registered: {humanize_list(list(map(inline, keys.keys())))}" await ctx.send(message) - @checks.is_owner() + @commands.is_owner() @authgg.group() async def roles(self, ctx): """Control what roles have access to reseting a user's HWID""" diff --git a/authgg/info.json b/authgg/info.json index cd842117..bb97f7d0 100644 --- a/authgg/info.json +++ b/authgg/info.json @@ -11,4 +11,4 @@ ], "requirements": [], "hidden": false -} \ No newline at end of file +} diff --git a/color/__init__.py b/color/__init__.py index 6fe8d04a..ce9bc2e6 100644 --- a/color/__init__.py +++ b/color/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Color(bot)) +async def setup(bot): + await bot.add_cog(Color(bot)) diff --git a/color/color.py b/color/color.py index 0f303933..c95b1337 100644 --- a/color/color.py +++ b/color/color.py @@ -26,7 +26,7 @@ import re import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from colour import Color as col from colour import rgb2hex @@ -147,7 +147,7 @@ async def color(self, ctx): """Group command for color commands""" pass - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @color.command() async def name(self, ctx, name): """Provides the hexadecimal value, RGB value and HSL value of a passed color. For example, pass `red` or `blue` as the name argument.""" @@ -159,7 +159,7 @@ async def name(self, ctx, name): except (ValueError, AttributeError): await ctx.send("That color is not recognized.") - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @color.command() async def hex(self, ctx, hexa: str): """Provides the RGB value and HSL value of a passed hexadecimal value. Hexadecimal value must in the format of something like `#ffffff` or `0xffffff` to be used.""" @@ -175,7 +175,7 @@ async def hex(self, ctx, hexa: str): "Invalid formatting for the hexadecimal. Must be the hexadecimal value, with an optional `0x` or `#` in the beginning." ) - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @color.command() async def rgb(self, ctx, highest: int, r: float, g: float, b: float): """Provides the hexadecimal value and HSL value of the rgb value given. Each value must have a space between them. Highest argument must be 1 or 255, indicating the highest value of a single value (r, g, or b).""" @@ -192,7 +192,7 @@ async def rgb(self, ctx, highest: int, r: float, g: float, b: float): except (ValueError, AttributeError): await ctx.send("That rgb number is not recognized.") - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @color.command() async def hsl(self, ctx, h: float, s: float, l: float): """Provides the hexadecimal value and the RGB value of the hsl value given. Each value must have a space between them.""" @@ -203,7 +203,7 @@ async def hsl(self, ctx, h: float, s: float, l: float): except (ValueError, AttributeError): await ctx.send("That hsl number is not recognized.") - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @color.command() async def decimal(self, ctx, decimal: int): """Provides the RGB value of the decimal value given.""" @@ -213,7 +213,7 @@ async def decimal(self, ctx, decimal: int): except (ValueError, AttributeError): await ctx.send("That decimal value is not recognized.") - @checks.admin() + @commands.admin() @color.command() async def msgshort(self, ctx, enable: bool): """Enable or disable the in-message shortcut. diff --git a/color/info.json b/color/info.json index 2befbef9..64b28a53 100644 --- a/color/info.json +++ b/color/info.json @@ -1,10 +1,17 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog. In-message shortcuts are disabled by guild by default. An administrator can change this rule by running `[p]color msgshort true`", - "name" : "color", - "short" : "Tells you the hexadecimal values, rgb values and names of colors", - "description" : "This cog will tell you the hexadecimal value, rgb value and the name of the color that is supplied to it.", - "tags" : ["tools"], - "requirements" : ["colour", "pillow"], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog. In-message shortcuts are disabled by guild by default. An administrator can change this rule by running `[p]color msgshort true`", + "name": "color", + "short": "Tells you the hexadecimal values, rgb values and names of colors", + "description": "This cog will tell you the hexadecimal value, rgb value and the name of the color that is supplied to it.", + "tags": [ + "tools" + ], + "requirements": [ + "colour", + "pillow" + ], + "hidden": false +} diff --git a/commandchart/__init__.py b/commandchart/__init__.py index 1d2e19a2..53114c19 100644 --- a/commandchart/__init__.py +++ b/commandchart/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(CommandChart(bot)) +async def setup(bot): + await bot.add_cog(CommandChart(bot)) diff --git a/commandchart/commandchart.py b/commandchart/commandchart.py index 4eb4d4b1..1d6bd7a7 100644 --- a/commandchart/commandchart.py +++ b/commandchart/commandchart.py @@ -6,7 +6,7 @@ """ MIT License -Copyright (c) 2018-Present NeuroAssassin +Copyright (c) 2018-Present NeuroAssassin Copyright (c) 2016-present aikaterna Permission is hereby granted, free of charge, to any person obtaining a copy @@ -34,7 +34,7 @@ from io import BytesIO import discord -from redbot.core import checks, commands +from redbot.core import commands import matplotlib import matplotlib.pyplot as plt @@ -127,11 +127,11 @@ def create_chart(self, top, others, channel): image_object.seek(0) return image_object - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @commands.guild_only() @commands.command() async def commandchart( - self, ctx, channel: typing.Optional[discord.TextChannel] = None, number: int = 5000, + self, ctx, channel: typing.Optional[discord.TextChannel] = None, number: int = 5000 ): """See the used commands in a certain channel within a certain amount of messages.""" e = discord.Embed(description="Loading...", color=0x000099) diff --git a/commandchart/info.json b/commandchart/info.json index cc61695f..ddd3cb55 100644 --- a/commandchart/info.json +++ b/commandchart/info.json @@ -1,10 +1,16 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "commandchart", - "short" : "Tells the used and usages of commands! Based off of aikaterna's chatchart cog.", - "description" : "This cog tells a Discord User the commands used, and the usage of them, in the last so and so messages. Based off of aikaterna's chatchart cog.", - "tags" : ["tools"], - "requirements" : ["matplotlib"], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "commandchart", + "short": "Tells the used and usages of commands! Based off of aikaterna's chatchart cog.", + "description": "This cog tells a Discord User the commands used, and the usage of them, in the last so and so messages. Based off of aikaterna's chatchart cog.", + "tags": [ + "tools" + ], + "requirements": [ + "matplotlib" + ], + "hidden": false +} diff --git a/cooldown/__init__.py b/cooldown/__init__.py index ef327035..049f61e4 100644 --- a/cooldown/__init__.py +++ b/cooldown/__init__.py @@ -1,5 +1,5 @@ from .cooldown import Cooldown -def setup(bot): - bot.add_cog(Cooldown(bot)) +async def setup(bot): + await bot.add_cog(Cooldown(bot)) diff --git a/cooldown/cooldown.py b/cooldown/cooldown.py index ff528067..1bd0a310 100644 --- a/cooldown/cooldown.py +++ b/cooldown/cooldown.py @@ -22,7 +22,7 @@ SOFTWARE. """ -from redbot.core import commands, checks, Config +from redbot.core import commands, Config from discord.ext import commands as dc import asyncio import time @@ -34,7 +34,8 @@ class Cooldown(commands.Cog): WARNING: Some cooldowns are meant to be in place, meaning that they should not be removed. Any contributors to this cog are not at fault if it is used improperly, and is instead at - the fault of the person running the command. By installing this cog, you agree to these terms.""" + the fault of the person running the command. By installing this cog, you agree to these terms. + """ def __init__(self, bot): self.bot = bot @@ -63,7 +64,7 @@ async def initialize(self): } commands.cooldown(entry[1], entry[2], switch[entry[3]])(cmd) - @checks.is_owner() + @commands.is_owner() @commands.group() async def cooldown(self, ctx): """Group command for working with cooldowns for commands.""" @@ -99,7 +100,8 @@ async def add(self, ctx, rate: int, per, btype, *, command): - Rate: how many times - Per: during how long - Type: for what type - - Command: for what command. Do not use a prefix, and does not work with aliases. Please pass the actual command for the alias if you wish.""" + - Command: for what command. Do not use a prefix, and does not work with aliases. Please pass the actual command for the alias if you wish. + """ ttype = None per = per.lower() np = per[:-1] @@ -191,7 +193,8 @@ async def remove(self, ctx, *, command): Please do note however: some commands are meant to have cooldowns. They may prevent something malicious from happening, or maybe your device from breaking or from being used too much. I (Neuro Assassin <@473541068378341376>) or any other contributor to this cog take no responsibility for any complications that may result because of this. Use at your own risk. - Note: Does not actually remove the command cooldown (undocumented), so instead it allows for the command to be run 100000 times every 1 second until the next boot up, where it will not be added (unless you are removing a cooldown from outside of this cog, then it will be kept after restart).""" + Note: Does not actually remove the command cooldown (undocumented), so instead it allows for the command to be run 100000 times every 1 second until the next boot up, where it will not be added (unless you are removing a cooldown from outside of this cog, then it will be kept after restart). + """ cmd = self.bot.get_command(command) if cmd == None or not str(cmd) == command: return await ctx.send("Invalid command argument.") diff --git a/cooldown/info.json b/cooldown/info.json index 7964acc3..f738d47a 100644 --- a/cooldown/info.json +++ b/cooldown/info.json @@ -10,4 +10,4 @@ "tools" ], "hidden": false -} \ No newline at end of file +} diff --git a/dashboard/abc/mixin.py b/dashboard/abc/mixin.py index d473fe4a..eda0d0f2 100644 --- a/dashboard/abc/mixin.py +++ b/dashboard/abc/mixin.py @@ -8,6 +8,6 @@ async def dashboard(self, ctx: commands.Context): class DBMixin: - """ This is mostly here to easily mess with things... """ + """This is mostly here to easily mess with things...""" c = dashboard diff --git a/dashboard/abc/roles.py b/dashboard/abc/roles.py index cf9b12de..45d11b8e 100644 --- a/dashboard/abc/roles.py +++ b/dashboard/abc/roles.py @@ -182,7 +182,7 @@ async def perms(self, ctx: commands.Context): disallowed = await self.config.disallowedperms() if await ctx.embed_requested(): e = discord.Embed( - title="Dashboard permissions", description="", color=(await ctx.embed_color()), + title="Dashboard permissions", description="", color=(await ctx.embed_color()) ) for key, value in HUMANIZED_PERMISSIONS.items(): if key in disallowed: diff --git a/dashboard/abc/webserver.py b/dashboard/abc/webserver.py index 905ccf46..56cb9105 100644 --- a/dashboard/abc/webserver.py +++ b/dashboard/abc/webserver.py @@ -80,11 +80,11 @@ async def redirect(self, ctx: commands.Context, redirect: str): @webserver.command(hidden=True) async def clientid(self, ctx: commands.Context, cid: int): """Set the Client ID for after logging in via Discord OAuth. - + Note that this should almost never be used. This is only here for special cases where the Client ID is not the same as the bot ID. - + Pass 0 if you wish to revert to Bot ID.""" await ctx.send( "**Warning**\n\nThis command only exists for special cases. It is most likely that your client ID is your bot ID, which is the default. **Changing this will break Discord OAuth until reverted.** Are you sure you want to do this?" diff --git a/dashboard/dashboard.py b/dashboard/dashboard.py index 01b4364c..6c44f3f7 100644 --- a/dashboard/dashboard.py +++ b/dashboard/dashboard.py @@ -33,7 +33,6 @@ class Dashboard( commands.Cog, metaclass=CompositeMetaClass, ): - __version__ = "0.1.8a" def __init__(self, bot: Red, *args, **kwargs): diff --git a/dashboard/info.json b/dashboard/info.json index 7fb80250..4d062c98 100644 --- a/dashboard/info.json +++ b/dashboard/info.json @@ -13,4 +13,4 @@ "markdown2" ], "hidden": true -} \ No newline at end of file +} diff --git a/dashboard/rpc/permissions.py b/dashboard/rpc/permissions.py index 8876fe01..45f667f0 100644 --- a/dashboard/rpc/permissions.py +++ b/dashboard/rpc/permissions.py @@ -173,7 +173,7 @@ async def add_default_rule( return {"status": 0, "message": "That command can not be restricted"} await cog._set_default_rule( - rule=cast(bool, allow_or_deny), cog_or_cmd=cog_or_command, guild_id=guild.id, + rule=cast(bool, allow_or_deny), cog_or_cmd=cog_or_command, guild_id=guild.id ) return {"status": 1} @@ -196,7 +196,7 @@ async def remove_rule( return {"status": 0, "message": "Invalid target"} await cog._remove_rule( - cog_or_cmd=cog_or_command, model_id=who_or_what.id, guild_id=guild.id, + cog_or_cmd=cog_or_command, model_id=who_or_what.id, guild_id=guild.id ) return {"status": 1} @@ -216,8 +216,6 @@ async def remove_default_rule( if isinstance(cog_or_command.obj, commands._AlwaysAvailableCommand): return {"status": 0, "message": "That command can not be restricted"} - await cog._set_default_rule( - rule=None, cog_or_cmd=cog_or_command, guild_id=guild.id, - ) + await cog._set_default_rule(rule=None, cog_or_cmd=cog_or_command, guild_id=guild.id) return {"status": 1} diff --git a/deleter/__init__.py b/deleter/__init__.py index 11a77704..66afb68f 100644 --- a/deleter/__init__.py +++ b/deleter/__init__.py @@ -5,6 +5,6 @@ ) -def setup(bot): +async def setup(bot): cog = Deleter(bot) - bot.add_cog(cog) + await bot.add_cog(cog) diff --git a/deleter/deleter.py b/deleter/deleter.py index fd324d6f..9cc8807a 100644 --- a/deleter/deleter.py +++ b/deleter/deleter.py @@ -28,7 +28,7 @@ from copy import deepcopy as dc import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.utils import AsyncIter from redbot.core.utils.chat_formatting import humanize_list @@ -36,7 +36,8 @@ class Deleter(commands.Cog): """Set channels for their messages to be auto-deleted after a specified amount of time. - WARNING: This cog has potential API abuse AND SHOULD BE USED CAREFULLY! If you see any issues arise due to this, please report to Neuro Assassin or bot owner ASAP!""" + WARNING: This cog has potential API abuse AND SHOULD BE USED CAREFULLY! If you see any issues arise due to this, please report to Neuro Assassin or bot owner ASAP! + """ def __init__(self, bot): self.bot = bot @@ -92,29 +93,29 @@ async def on_message(self, message): c["messages"][str(message.id)] = time.time() + int(c["wait"]) await self.conf.channel(message.channel).messages.set(c["messages"]) - @commands.group() + @commands.group(invoke_without_command=True) @commands.guild_only() - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) async def deleter(self, ctx): """Group command for commands dealing with auto-timed deletion. - To see what channels are currently being tracked, use this command with no subcommands passed.""" - if ctx.invoked_subcommand is None: - async with self.lock: - channels = await self.conf.all_channels() - sending = "" - for c, data in channels.items(): - c = self.bot.get_channel(int(c)) - if c is None: - continue - if c.guild.id == ctx.guild.id and int(data["wait"]) != 0: - sending += f"{c.mention}: {data['wait']} seconds\n" - if sending: - await ctx.send(sending) - else: - await ctx.send( - f"No channels are currently being tracked. Add one by using `{ctx.prefix}deleter channel`." - ) + To see what channels are currently being tracked, use this command with no subcommands passed. + """ + async with self.lock: + channels = await self.conf.all_channels() + sending = "" + for c, data in channels.items(): + c = self.bot.get_channel(int(c)) + if c is None: + continue + if c.guild.id == ctx.guild.id and int(data["wait"]) != 0: + sending += f"{c.mention}: {data['wait']} seconds\n" + if sending: + await ctx.send(sending) + else: + await ctx.send( + f"No channels are currently being tracked. Add one by using `{ctx.prefix}deleter channel`." + ) @deleter.command() async def channel(self, ctx, channel: discord.TextChannel, wait): diff --git a/deleter/info.json b/deleter/info.json index d06be5df..cff84c43 100644 --- a/deleter/info.json +++ b/deleter/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "deleter", - "short" : "Allows for the auto-deletion of messages in a channel after a specified wait time.", - "description" : "Allows moderators to make messages be auto-deleted after a certain amount of time in a certain channel. WARNING: This cog has potential API abuse AND SHOULD BE USED CAREFULLY! If you see any issues arise due to this, please report to Neuro Assassin or bot owner ASAP!", - "tags" : ["tools"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "deleter", + "short": "Allows for the auto-deletion of messages in a channel after a specified wait time.", + "description": "Allows moderators to make messages be auto-deleted after a certain amount of time in a certain channel. WARNING: This cog has potential API abuse AND SHOULD BE USED CAREFULLY! If you see any issues arise due to this, please report to Neuro Assassin or bot owner ASAP!", + "tags": [ + "tools" + ], + "requirements": [], + "hidden": false +} diff --git a/editor/__init__.py b/editor/__init__.py index a3066590..0aceaf7a 100644 --- a/editor/__init__.py +++ b/editor/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Editor(bot)) +async def setup(bot): + await bot.add_cog(Editor(bot)) diff --git a/editor/editor.py b/editor/editor.py index 7c324d82..186a836f 100644 --- a/editor/editor.py +++ b/editor/editor.py @@ -25,7 +25,7 @@ from typing import Union import discord -from redbot.core import checks, commands +from redbot.core import commands class Editor(commands.Cog): @@ -39,7 +39,7 @@ async def red_delete_data_for_user(self, **kwargs): return @commands.command() - @checks.admin() + @commands.admin() async def editmessage( self, ctx, ecid: int, editid: int, ccid: int, *, content: Union[int, str] ): diff --git a/editor/info.json b/editor/info.json index 041dc3e6..e4564d67 100644 --- a/editor/info.json +++ b/editor/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "editor", - "short" : "Edit one of the bot's messages easily.", - "description" : "Allows an administrator to change the text of one of the bot's messages, by either specifying the new content or by taking the content (and embed, if applicable) of another message.", - "tags" : ["tools"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "editor", + "short": "Edit one of the bot's messages easily.", + "description": "Allows an administrator to change the text of one of the bot's messages, by either specifying the new content or by taking the content (and embed, if applicable) of another message.", + "tags": [ + "tools" + ], + "requirements": [], + "hidden": false +} diff --git a/esolang/befunge.py b/esolang/befunge.py index 4ae7e4db..a0578cd1 100644 --- a/esolang/befunge.py +++ b/esolang/befunge.py @@ -50,7 +50,8 @@ def __init__(self, message: str, code: str): else: ptr = len(code) super().__init__( - message, ("program.befunge", 1, ptr, code), + message, + ("program.befunge", 1, ptr, code), ) diff --git a/esolang/cow.py b/esolang/cow.py index 7ea92496..f231c321 100644 --- a/esolang/cow.py +++ b/esolang/cow.py @@ -2,7 +2,6 @@ class COW: - instruction_mapping = { 0: "moo", 1: "mOo", diff --git a/esolang/esolang.py b/esolang/esolang.py index 355fe029..f3213386 100644 --- a/esolang/esolang.py +++ b/esolang/esolang.py @@ -127,8 +127,7 @@ async def whitespace(self, ctx, *, code): Since Discord auto-converts tabs to spaces, use EM QUAD instead. - If you need to copy it, here: `  -` + If you need to copy it, here: `\u2001` """ try: wrapped = functools.partial(Whitespace.evaluate, code=code) @@ -148,4 +147,9 @@ async def whitespace(self, ctx, *, code): else: output.seek(0) output = output.read() - await ctx.send(box(f"[Output]: {output}", lang="ini",)) + await ctx.send( + box( + f"[Output]: {output}", + lang="ini", + ) + ) diff --git a/esolang/info.json b/esolang/info.json index a970edcc..283ad78d 100644 --- a/esolang/info.json +++ b/esolang/info.json @@ -11,4 +11,4 @@ ], "requirements": [], "hidden": true -} \ No newline at end of file +} diff --git a/esolang/whitespace.py b/esolang/whitespace.py index cd64d225..72edc70b 100644 --- a/esolang/whitespace.py +++ b/esolang/whitespace.py @@ -15,7 +15,8 @@ def __init__(self, message: str, code: str, pointer: int): else: line = 0 super().__init__( - message, ("program.ws", line + 1, pointer + 1, code), + message, + ("program.ws", line + 1, pointer + 1, code), ) @@ -31,7 +32,8 @@ def __init__(self, message: str, code: str, pointer: int): else: line = 0 super().__init__( - message, ("program.ws", line + 1, pointer + 1, code), + message, + ("program.ws", line + 1, pointer + 1, code), ) diff --git a/evolution/__init__.py b/evolution/__init__.py index bd82043b..45904e17 100644 --- a/evolution/__init__.py +++ b/evolution/__init__.py @@ -17,5 +17,5 @@ async def setup(bot): if not is_global: raise RuntimeError("Bank must be global for this cog to work.") cog = Evolution(bot) - bot.add_cog(cog) + await bot.add_cog(cog) await cog.utils.initialize() diff --git a/evolution/bank.py b/evolution/bank.py index a382ffa9..89e217c4 100644 --- a/evolution/bank.py +++ b/evolution/bank.py @@ -50,7 +50,7 @@ "BankPruneError", ] -_MAX_BALANCE = 2 ** 63 - 1 +_MAX_BALANCE = 2**63 - 1 _DEFAULT_MEMBER = {"balance": 0, "next_payday": 0} diff --git a/evolution/evolution.py b/evolution/evolution.py index baf6c7fd..1a4105b2 100644 --- a/evolution/evolution.py +++ b/evolution/evolution.py @@ -32,7 +32,7 @@ from typing import Literal, Optional import discord -from redbot.core import Config, checks, commands, errors +from redbot.core import Config, commands, errors from redbot.core.bot import Red from redbot.core.utils import AsyncIter from redbot.core.utils.chat_formatting import box, humanize_number, humanize_timedelta, inline @@ -124,7 +124,7 @@ async def deletemydata(self, ctx, check: bool = False): await self.red_delete_data_for_user(requester="user", user_id=ctx.author.id) await ctx.send("Data deleted. Your game data has been reset.") - @checks.is_owner() + @commands.is_owner() @evolution.group() async def tasks(self, ctx): """View the status of the cog tasks. @@ -141,7 +141,7 @@ async def income(self, ctx): message = self.utils.format_task(statuses["income"]) await ctx.send(message) - @checks.is_owner() + @commands.is_owner() @evolution.command(hidden=True) async def removeuser(self, ctx, user: discord.User): """Removes a user from the market place if they are stuck for some reason. @@ -316,7 +316,7 @@ async def shop(self, ctx, start_level: int = None): embed_list = [] for x in range(1, max(list(map(int, animals.keys()))) + 1): embed = discord.Embed( - title=f"{animal.title()} Shop", description=f"Level {str(x)}", color=0xD2B48C, + title=f"{animal.title()} Shop", description=f"Level {str(x)}", color=0xD2B48C ) embed.add_field(name="You currently own", value=animals.get(str(x), 0)) current = int(bought.get(str(x), 0)) @@ -349,7 +349,7 @@ async def shop(self, ctx, start_level: int = None): if highest_level < 0: highest_level = 0 - controls = copy.deepcopy(DEFAULT_CONTROLS) + controls = dict(DEFAULT_CONTROLS) controls["\N{MONEY BAG}"] = self.utils.shop_control_callback await menu(ctx, embed_list, controls, page=highest_level) @@ -362,7 +362,8 @@ async def daily(self, ctx): Status guide: A: Available to be bought and put in backyard B: Already purchased - S: Available to be bought, but will be put in stash because you either do not have the space for the, or above your level threshold""" + S: Available to be bought, but will be put in stash because you either do not have the space for the, or above your level threshold + """ async with self.lock: data = await self.conf.user(ctx.author).all() animals = data["animals"] @@ -591,7 +592,7 @@ async def perk(self, ctx, *, name: str): """Claim a perk from your stash""" return await ctx.send("This command is not available. Check back soon!") - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @evolution.command(aliases=["by"]) async def backyard(self, ctx, use_menu: bool = False): """Where ya animals live! Pass 1 or true to put it in a menu.""" diff --git a/evolution/info.json b/evolution/info.json index 02528d98..83c0c6c6 100644 --- a/evolution/info.json +++ b/evolution/info.json @@ -1,10 +1,16 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog. This cog requires for the bank to be global in order to be used.", - "name" : "evolution", - "short" : "Buy and get animals to get more economy credits!", - "description" : "Buy animals using economy credits or get them every 10 minutes, and gain a certain amount of credits every minute!", - "tags" : ["fun"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog. This cog requires for the bank to be global in order to be used.", + "name": "evolution", + "short": "Buy and get animals to get more economy credits!", + "description": "Buy animals using economy credits or get them every 10 minutes, and gain a certain amount of credits every minute!", + "tags": [ + "fun" + ], + "requirements": [ + "tabulate" + ], + "hidden": false +} diff --git a/evolution/utils.py b/evolution/utils.py index dc12905d..99707681 100644 --- a/evolution/utils.py +++ b/evolution/utils.py @@ -22,7 +22,7 @@ def get_total_price(level, bought, amount, bt=True): total = 0 for x in range(amount): normal = level * 800 - level_tax = ((2 ** level) * 10) - 200 + level_tax = ((2**level) * 10) - 200 if bt: tax = bought * 300 extra = x * 300 diff --git a/grammar/__init__.py b/grammar/__init__.py index d963479b..d0e2fce8 100644 --- a/grammar/__init__.py +++ b/grammar/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Grammar(bot)) +async def setup(bot): + await bot.add_cog(Grammar(bot)) diff --git a/grammar/converters.py b/grammar/converters.py index 96c19006..49d021c9 100644 --- a/grammar/converters.py +++ b/grammar/converters.py @@ -1,4 +1,4 @@ -# Large pieces of the argument parser is taken from Sinbad's cogs. I based mine off of https://github.com/mikeshardmind/SinbadCogs/blob/v3/scheduler/converters.py#L23 +# Large pieces of the argument parser is taken from Sinbad's cogs. I based mine off of https://github.com/mikeshardmind/SinbadCogs/blob/d59fd7bc69833dc24f9e74ec59e635ffe593d43f/scheduler/converters.py#L23 import argparse diff --git a/grammar/info.json b/grammar/info.json new file mode 100644 index 00000000..6e1fbd41 --- /dev/null +++ b/grammar/info.json @@ -0,0 +1,12 @@ +{ + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "grammer", + "short": "Get words related to the specified arguments", + "description": "Get words related to the specified arguments", + "tags": [], + "requirements": [], + "hidden": false +} diff --git a/info.json b/info.json index 2be594cc..16b78100 100644 --- a/info.json +++ b/info.json @@ -1,8 +1,13 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thanks for adding my repo. Join the support server for help:\nhttps://discord.gg/vQZTdB9", - "name" : "Toxic Cogs", - "short" : "Holds cogs made by Neuro Assassin.", - "description" : "This repo holds the several different cogs, for Red - Discord Bot by TwentySix.", - "tags" : ["fun", "tools"] -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thanks for adding my repo. Join the support server for help:\nhttps://discord.gg/vQZTdB9", + "name": "Toxic Cogs", + "short": "Holds cogs made by Neuro Assassin.", + "description": "This repo holds the several different cogs, for Red - Discord Bot by TwentySix.", + "tags": [ + "fun", + "tools" + ] +} diff --git a/listpermissions/__init__.py b/listpermissions/__init__.py index fddd23fc..fed1850c 100644 --- a/listpermissions/__init__.py +++ b/listpermissions/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(ListPermissions(bot)) +async def setup(bot): + await bot.add_cog(ListPermissions(bot)) diff --git a/listpermissions/info.json b/listpermissions/info.json index 4928221e..5da68bc6 100644 --- a/listpermissions/info.json +++ b/listpermissions/info.json @@ -1,10 +1,17 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "listpermissions", - "short" : "Gives you the permissions of a role/member guild wide or in a channel", - "description" : "This cog will allow you to see all permissions, available permissions or denied permissions or a role or member across the guild or in a channel. Do note however that the `[p](groupcommand) channel role` only provides basic permissions, and will only tell what is different for the channel compared to the guild permissions for a role.", - "tags" : ["tools"], - "requirements" : ["prettytable", "fuzzywuzzy"], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "listpermissions", + "short": "Gives you the permissions of a role/member guild wide or in a channel", + "description": "This cog will allow you to see all permissions, available permissions or denied permissions or a role or member across the guild or in a channel. Do note however that the `[p](groupcommand) channel role` only provides basic permissions, and will only tell what is different for the channel compared to the guild permissions for a role.", + "tags": [ + "tools" + ], + "requirements": [ + "prettytable", + "fuzzywuzzy" + ], + "hidden": false +} diff --git a/maintenance/__init__.py b/maintenance/__init__.py index e761b331..48116608 100644 --- a/maintenance/__init__.py +++ b/maintenance/__init__.py @@ -9,4 +9,4 @@ async def setup(bot): cog = Maintenance(bot) - bot.add_cog(cog) + await bot.add_cog(cog) diff --git a/maintenance/converters.py b/maintenance/converters.py index 75e5b9db..62642ee8 100644 --- a/maintenance/converters.py +++ b/maintenance/converters.py @@ -1,4 +1,4 @@ -# Large pieces of the argument parser is taken from Sinbad's cogs. I based mine off of https://github.com/mikeshardmind/SinbadCogs/blob/v3/scheduler/converters.py#L23 +# Large pieces of the argument parser is taken from Sinbad's cogs. I based mine off of https://github.com/mikeshardmind/SinbadCogs/blob/d59fd7bc69833dc24f9e74ec59e635ffe593d43f/scheduler/converters.py#L23 import argparse import time @@ -38,7 +38,7 @@ async def convert(self, ctx, argument): if start_seconds: if end_seconds: scheduled = ScheduledMaintenance( - start=start_seconds, end=end_seconds, after=after, whitelist=whitelist, + start=start_seconds, end=end_seconds, after=after, whitelist=whitelist ) else: scheduled = ScheduledMaintenance(start=start_seconds, whitelist=whitelist) diff --git a/maintenance/info.json b/maintenance/info.json index e8ee3b7a..ea5a6faf 100644 --- a/maintenance/info.json +++ b/maintenance/info.json @@ -1,9 +1,13 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "maintenance", - "short" : "Allows the bot owner to put the bot on maintenance.", - "description" : "Allows the owner to put the bot on maintenance, and specify when the maintenance will be over (but does not have to). The bot owner can also whitelist users from the maintenance.", - "tags" : ["tools"], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "maintenance", + "short": "Allows the bot owner to put the bot on maintenance.", + "description": "Allows the owner to put the bot on maintenance, and specify when the maintenance will be over (but does not have to). The bot owner can also whitelist users from the maintenance.", + "tags": [ + "tools" + ], + "hidden": false +} diff --git a/maintenance/maintenance.py b/maintenance/maintenance.py index 1415fe67..c1594360 100644 --- a/maintenance/maintenance.py +++ b/maintenance/maintenance.py @@ -28,7 +28,7 @@ from typing import Literal import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from .converters import Margs @@ -131,7 +131,7 @@ async def this_check(self, ctx): raise LIStsSTaRtaTiNDeX1(message) return False - @checks.is_owner() + @commands.is_owner() @commands.group() async def maintenance(self, ctx): """Control the bot's maintenance.""" @@ -150,7 +150,8 @@ async def _on(self, ctx, *, args: Margs = None): Examples: `[p]maintenance on --start-in 5 seconds`; starts a maintenance in 5 seconds `[p]maintenance on --start-in 5 seconds --end-in 10 seconds`; starts a maintenance in 5 seconds, then scheduled to end in 10 seconds, so it will only be on maintenance for 5 seconds. - `[p]maintenance on --start-in 10 seconds --end-after 10 seconds --whitelist 473541068378341376 473541068378341377`; starts a maintenance in 10 seconds, that lasts for 10 seconds after, and has the two user IDs who are exempted from the maintenance.""" + `[p]maintenance on --start-in 10 seconds --end-after 10 seconds --whitelist 473541068378341376 473541068378341377`; starts a maintenance in 10 seconds, that lasts for 10 seconds after, and has the two user IDs who are exempted from the maintenance. + """ on = await self.conf.on() if on[0]: return await ctx.send( diff --git a/make.bat b/make.bat index 51127b3a..12d83e65 100644 --- a/make.bat +++ b/make.bat @@ -8,15 +8,15 @@ setlocal ENABLEDELAYEDEXPANSION goto %1 :reformat -black -l 99 . +black . exit /B %ERRORLEVEL% :stylecheck -black --check -l 99 . +black --check . exit /B %ERRORLEVEL% :stylediff -black --check --diff -l 99 . +black --check --diff . exit /B %ERRORLEVEL% :help @@ -25,4 +25,4 @@ echo make ^ echo. echo Commands: echo reformat Reformat all .py files being tracked by git. -echo stylecheck Check which tracked .py files need reformatting. \ No newline at end of file +echo stylecheck Check which tracked .py files need reformatting. diff --git a/minesweeper/__init__.py b/minesweeper/__init__.py index 7f46dcc4..fce50742 100644 --- a/minesweeper/__init__.py +++ b/minesweeper/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Minesweeper(bot)) +async def setup(bot): + await bot.add_cog(Minesweeper(bot)) diff --git a/minesweeper/info.json b/minesweeper/info.json index 9a352384..b305006d 100644 --- a/minesweeper/info.json +++ b/minesweeper/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.\nSmall warning: this cog can sometimes you up rate limits (depending how fast you play), so be careful while playing.", - "name" : "minesweeper", - "short" : "Allows you to play Minesweeper inside of Discord!\nSmall warning: this cog can sometimes you up rate limits (depending how fast you play), so be careful while playing.", - "description" : "This cog allows a Discord User to play the game Minesweeper inside of a text channel.\nSmall warning: this cog can sometimes you up rate limits (depending how fast you play), so be careful while playing.", - "tags" : ["fun"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.\nSmall warning: this cog can sometimes you up rate limits (depending how fast you play), so be careful while playing.", + "name": "minesweeper", + "short": "Allows you to play Minesweeper inside of Discord!\nSmall warning: this cog can sometimes you up rate limits (depending how fast you play), so be careful while playing.", + "description": "This cog allows a Discord User to play the game Minesweeper inside of a text channel.\nSmall warning: this cog can sometimes you up rate limits (depending how fast you play), so be careful while playing.", + "tags": [ + "fun" + ], + "requirements": [], + "hidden": false +} diff --git a/minesweeper/minesweeper.py b/minesweeper/minesweeper.py index d21362bf..fb9202b5 100644 --- a/minesweeper/minesweeper.py +++ b/minesweeper/minesweeper.py @@ -341,7 +341,8 @@ def add_desc(self, board): async def minesweeper(self, ctx, bombs: int = "Random bomb amount"): """Starts a game of minesweeper. - You can specify the amount of wanted bombs using the bomb paramater. It must be between 10 bombs and 99 bombs, and defaults to random between 15 to 25.""" + You can specify the amount of wanted bombs using the bomb paramater. It must be between 10 bombs and 99 bombs, and defaults to random between 15 to 25. + """ if isinstance(bombs, str): bombs = random.randint(15, 25) if bombs < 10 or bombs > 99: @@ -422,8 +423,9 @@ def check(m): @commands.command() async def spoilerms(self, ctx, bombs: int = "Random bomb amount"): """Starts a non-interactive game of minesweeper with spoilers. - - You can specify the amount of wanted bombs using the bomb paramater. It must be between 10 bombs and 99 bombs, and defaults to random between 15 to 25.""" + + You can specify the amount of wanted bombs using the bomb paramater. It must be between 10 bombs and 99 bombs, and defaults to random between 15 to 25. + """ if isinstance(bombs, str): bombs = random.randint(15, 25) if bombs < 10 or bombs > 99: diff --git a/opensea/__init__.py b/opensea/__init__.py index 3dd2157b..a247aa7c 100644 --- a/opensea/__init__.py +++ b/opensea/__init__.py @@ -1,5 +1,5 @@ from .opensea import OpenSea -def setup(bot): - bot.add_cog(OpenSea(bot)) +async def setup(bot): + await bot.add_cog(OpenSea(bot)) diff --git a/opensea/info.json b/opensea/info.json index 85265744..cf6b1eed 100644 --- a/opensea/info.json +++ b/opensea/info.json @@ -11,4 +11,4 @@ ], "requirements": [], "hidden": false -} \ No newline at end of file +} diff --git a/opensea/opensea.py b/opensea/opensea.py index bee265eb..9b9929b7 100644 --- a/opensea/opensea.py +++ b/opensea/opensea.py @@ -1,5 +1,5 @@ from redbot.core.utils.chat_formatting import pagify -from redbot.core import Config, commands, checks +from redbot.core import Config, commands from redbot.core.bot import Red from datetime import datetime from typing import Optional @@ -169,7 +169,7 @@ async def publish_update(self, subscribed, event): embed.set_thumbnail(url=event["asset"]["collection"]["image_url"]) embed.add_field(name="Name", value=event["asset"]["name"], inline=True) embed.add_field( - name="Amount", value=str(int(event["total_price"]) / (10 ** 18)) + "Ξ", inline=True + name="Amount", value=str(int(event["total_price"]) / (10**18)) + "Ξ", inline=True ) if event["winner_account"]["user"] and event["winner_account"]["user"]["username"]: @@ -207,7 +207,7 @@ async def publish_update(self, subscribed, event): return remove_channels - @checks.mod_or_permissions(manage_messages=True) + @commands.mod_or_permissions(manage_messages=True) @commands.group(aliases=["os"]) async def opensea(self, ctx): """Receive events from OpenSea regarding assets.""" @@ -355,7 +355,7 @@ async def listaddresses(self, ctx, channel: Optional[discord.TextChannel]): for page in pagify(message, delims=["\n", ","]): await ctx.send(page) - @checks.is_owner() + @commands.is_owner() @opensea.command(hidden=True) async def forceupdate(self, ctx): """Force an update of all subscribed channels.""" diff --git a/pyproject.toml b/pyproject.toml new file mode 100644 index 00000000..ad8d0916 --- /dev/null +++ b/pyproject.toml @@ -0,0 +1,3 @@ +[tool.black] + line-length = 99 + required-version = '23' diff --git a/reacticket/__init__.py b/reacticket/__init__.py index f4e12a59..f1ae951b 100644 --- a/reacticket/__init__.py +++ b/reacticket/__init__.py @@ -1,5 +1,5 @@ from .reacticket import ReacTicket -def setup(bot): - bot.add_cog(ReacTicket(bot)) +async def setup(bot): + await bot.add_cog(ReacTicket(bot)) diff --git a/reacticket/extensions/base.py b/reacticket/extensions/base.py index 8c98c7f0..70987931 100644 --- a/reacticket/extensions/base.py +++ b/reacticket/extensions/base.py @@ -7,7 +7,7 @@ from reacticket.extensions.abc import MixinMeta -from reacticket.extensions.mixin import reacticket +from reacticket.extensions.mixin import RTMixin if discord.__version__ == "2.0.0a" or TYPE_CHECKING: from reacticket.extensions.views.queue import Queue @@ -39,9 +39,7 @@ async def report_close(self, ctx, ticket, author, guild_settings, reason): "mention", "Unknown moderator", ) - embed.add_field( - name="Assigned moderator", value=moderator, - ) + embed.add_field(name="Assigned moderator", value=moderator) await reporting_channel.send(embed=embed) else: @@ -159,7 +157,7 @@ async def process_closed_ticket( "permission in the category." ) - @reacticket.command() + @RTMixin.reacticket.command() async def close(self, ctx, *, reason=None): """Closes the created ticket. @@ -244,7 +242,7 @@ async def close(self, ctx, *, reason=None): added_users=added_users, ) - @reacticket.command(name="add") + @RTMixin.reacticket.command(name="add") async def ticket_add(self, ctx, user: discord.Member): """Add a user to the current ticket.""" guild_settings = await self.config.guild(ctx.guild).all() @@ -329,7 +327,7 @@ async def ticket_add(self, ctx, user: discord.Member): await ctx.send(f"{user.mention} has been added to the ticket.") - @reacticket.command(name="remove") + @RTMixin.reacticket.command(name="remove") async def ticket_remove(self, ctx, user: discord.Member): """Remove a user from the current ticket.""" guild_settings = await self.config.guild(ctx.guild).all() @@ -411,7 +409,7 @@ async def ticket_remove(self, ctx, user: discord.Member): await ctx.send(f"{user.mention} has been removed from the ticket.") - @reacticket.command(name="name") + @RTMixin.reacticket.command(name="name") async def ticket_name(self, ctx, *, name: str): """Rename the ticket in scope.""" guild_settings = await self.config.guild(ctx.guild).all() @@ -544,7 +542,7 @@ async def predicate(ctx): return commands.check(predicate) @is_support_or_superior() - @reacticket.command(aliases=["unlock"]) + @RTMixin.reacticket.command(aliases=["unlock"]) async def lock(self, ctx, channel: Optional[discord.TextChannel] = None): """Lock the specified ticket channel. If no channel is provided, defaults to current. @@ -591,7 +589,7 @@ async def assign_moderator( break @is_support_or_superior() - @reacticket.command(aliases=["moderator", "mod"]) + @RTMixin.reacticket.command(aliases=["moderator", "mod"]) async def assign( self, ctx, moderator: discord.Member, ticket: Optional[discord.TextChannel] = None ): @@ -673,7 +671,7 @@ def predicate(ctx): @on_discord_alpha() @is_support_or_superior() @commands.bot_has_permissions(embed_links=True) - @reacticket.command(aliases=["tickets"]) + @RTMixin.reacticket.command(aliases=["tickets"]) async def queue(self, ctx): """List, modify and close tickets sorted based upon when they were opened""" unsorted_tickets = await self.config.guild(ctx.guild).created() diff --git a/reacticket/extensions/basesettings.py b/reacticket/extensions/basesettings.py index 7722d7ef..de3506ab 100644 --- a/reacticket/extensions/basesettings.py +++ b/reacticket/extensions/basesettings.py @@ -6,11 +6,11 @@ import copy from reacticket.extensions.abc import MixinMeta -from reacticket.extensions.mixin import settings +from reacticket.extensions.mixin import RTMixin class ReacTicketBaseSettingsMixin(MixinMeta): - @settings.group(name="precreationsettings", aliases=["precs"]) + @RTMixin.settings.group(name="precreationsettings", aliases=["precs"]) async def pre_creation_settings(self, ctx): """Control the actions that are checked/occur before ticket is created""" pass @@ -131,7 +131,7 @@ async def maxtickets(self, ctx, number: int, send_dm: Optional[bool] = None): "Max number of tickets per user and DM setting have been successfully updated." ) - @settings.group(name="postcreationsettings", aliases=["postcs"]) + @RTMixin.settings.group(name="postcreationsettings", aliases=["postcs"]) async def post_creation_settings(self, ctx): """Control the actions that occur post the ticket being created""" pass @@ -311,7 +311,7 @@ async def ticket_names_select(self, ctx, index: int): await self.config.guild(ctx.guild).presetname.set(settings) await ctx.send("Successfully changed selected ticket name preset.") - @settings.command() + @RTMixin.settings.command() async def enable(self, ctx, yes_or_no: Optional[bool] = None): """Starts listening for the set Reaction on the set Message to process tickets""" # We'll run through a test of all the settings to ensure everything is set properly @@ -450,7 +450,7 @@ async def enable(self, ctx, yes_or_no: Optional[bool] = None): await ctx.send("All checks passed. Ticket system is now active.") - @settings.command() + @RTMixin.settings.command() async def disable(self, ctx): """Disable ticketing system""" await self.config.guild(ctx.guild).enabled.set(False) diff --git a/reacticket/extensions/closesettings.py b/reacticket/extensions/closesettings.py index 37e2be95..82742bc6 100644 --- a/reacticket/extensions/closesettings.py +++ b/reacticket/extensions/closesettings.py @@ -5,11 +5,11 @@ import contextlib from reacticket.extensions.abc import MixinMeta -from reacticket.extensions.mixin import settings +from reacticket.extensions.mixin import RTMixin class ReacTicketCloseSettingsMixin(MixinMeta): - @settings.group() + @RTMixin.settings.group() async def closesettings(self, ctx): """Control what actions occur when a ticket is closed""" pass diff --git a/reacticket/extensions/mixin.py b/reacticket/extensions/mixin.py index 2bff31ea..9e9f1d4a 100644 --- a/reacticket/extensions/mixin.py +++ b/reacticket/extensions/mixin.py @@ -1,49 +1,46 @@ from redbot.core import commands, checks -@checks.bot_has_permissions(add_reactions=True) -@commands.guild_only() -@commands.group(name="reacticket") -async def reacticket(self, ctx: commands.Context): - """Create a reaction ticket system in your server""" - pass - - -@checks.admin() -@reacticket.group(invoke_without_command=True, aliases=["set"]) -async def settings(self, ctx): - """Manage settings for ReacTicket""" - await ctx.send_help() - guild_settings = await self.config.guild(ctx.guild).all() - channel_id, message_id = list(map(int, guild_settings["msg"].split("-"))) - - ticket_channel = getattr(self.bot.get_channel(channel_id), "name", "Not set") - ticket_category = getattr(self.bot.get_channel(guild_settings["category"]), "name", "Not set") - archive_category = getattr( - self.bot.get_channel(guild_settings["archive"]["category"]), "name", "Not set" - ) - report_channel = getattr(self.bot.get_channel(guild_settings["report"]), "name", "Not set") - - await ctx.send( - "```ini\n" - f"[Ticket Channel]: {ticket_channel}\n" - f"[Ticket MessageID]: {message_id}\n" - f"[Ticket Reaction]: {guild_settings['reaction']}\n" - f"[User-closable]: {guild_settings['usercanclose']}\n" - f"[User-modifiable]: {guild_settings['usercanmodify']}\n" - f"[User-nameable]: {guild_settings['usercanclose']}\n" - f"[Ticket Category]: {ticket_category}\n" - f"[Report Channel]: {report_channel}\n" - f"[Ticket Close DM]: {guild_settings['dm']}\n" - f"[Archive Category]: {archive_category}\n" - f"[Archive Enabled]: {guild_settings['archive']['enabled']}\n" - f"[System Enabled]: {guild_settings['enabled']}\n" - "```" - ) - - class RTMixin: - """ This is mostly here to easily mess with things... """ - - c = reacticket - s = settings + """This is mostly here to easily mess with things...""" + + @checks.bot_has_permissions(add_reactions=True) + @commands.guild_only() + @commands.group(name="reacticket") + async def reacticket(self, ctx: commands.Context): + """Create a reaction ticket system in your server""" + pass + + @checks.admin() + @reacticket.group(invoke_without_command=True, aliases=["set"]) + async def settings(self, ctx): + """Manage settings for ReacTicket""" + await ctx.send_help() + guild_settings = await self.config.guild(ctx.guild).all() + channel_id, message_id = list(map(int, guild_settings["msg"].split("-"))) + + ticket_channel = getattr(self.bot.get_channel(channel_id), "name", "Not set") + ticket_category = getattr( + self.bot.get_channel(guild_settings["category"]), "name", "Not set" + ) + archive_category = getattr( + self.bot.get_channel(guild_settings["archive"]["category"]), "name", "Not set" + ) + report_channel = getattr(self.bot.get_channel(guild_settings["report"]), "name", "Not set") + + await ctx.send( + "```ini\n" + f"[Ticket Channel]: {ticket_channel}\n" + f"[Ticket MessageID]: {message_id}\n" + f"[Ticket Reaction]: {guild_settings['reaction']}\n" + f"[User-closable]: {guild_settings['usercanclose']}\n" + f"[User-modifiable]: {guild_settings['usercanmodify']}\n" + f"[User-nameable]: {guild_settings['usercanclose']}\n" + f"[Ticket Category]: {ticket_category}\n" + f"[Report Channel]: {report_channel}\n" + f"[Ticket Close DM]: {guild_settings['dm']}\n" + f"[Archive Category]: {archive_category}\n" + f"[Archive Enabled]: {guild_settings['archive']['enabled']}\n" + f"[System Enabled]: {guild_settings['enabled']}\n" + "```" + ) diff --git a/reacticket/extensions/usersettings.py b/reacticket/extensions/usersettings.py index a03d0e15..e6a935ef 100644 --- a/reacticket/extensions/usersettings.py +++ b/reacticket/extensions/usersettings.py @@ -1,11 +1,11 @@ from typing import Optional from reacticket.extensions.abc import MixinMeta -from reacticket.extensions.mixin import settings +from reacticket.extensions.mixin import RTMixin class ReacTicketUserSettingsMixin(MixinMeta): - @settings.group() + @RTMixin.settings.group() async def userpermissions(self, ctx): """Control the permissions that users have with their own tickets""" pass diff --git a/reacticket/extensions/views/ticket.py b/reacticket/extensions/views/ticket.py index 7bfb791a..fc89540c 100644 --- a/reacticket/extensions/views/ticket.py +++ b/reacticket/extensions/views/ticket.py @@ -79,7 +79,7 @@ async def build_embed(self): self.embed.add_field(name="Ticket Creation Date", value=timestamp, inline=True) @discord.ui.button( - label="Assign Moderator", style=discord.ButtonStyle.primary, emoji="\N{SHIELD}", + label="Assign Moderator", style=discord.ButtonStyle.primary, emoji="\N{SHIELD}" ) async def assign_moderator(self, button: discord.ui.Button, interaction: discord.Interaction): await interaction.response.defer() @@ -358,9 +358,7 @@ def check(message): self.repeat = True self.stop() - @discord.ui.button( - label="Lock Ticket", style=discord.ButtonStyle.danger, emoji="\N{LOCK}", - ) + @discord.ui.button(label="Lock Ticket", style=discord.ButtonStyle.danger, emoji="\N{LOCK}") async def toggle_ticket_lock( self, button: discord.ui.Button, interaction: discord.Interaction ): @@ -396,9 +394,7 @@ async def toggle_ticket_lock( self.ticket["locked"] = not self.ticket["locked"] self.stop() - @discord.ui.button( - label="Archive/Close Ticket", style=discord.ButtonStyle.danger, - ) + @discord.ui.button(label="Archive/Close Ticket", style=discord.ButtonStyle.danger) async def close_ticket(self, button: discord.ui.Button, interaction: discord.Interaction): guild_settings = await self.ctx.cog.config.guild(self.ctx.guild).all() diff --git a/reacticket/info.json b/reacticket/info.json index 84484916..fee5d9f5 100644 --- a/reacticket/info.json +++ b/reacticket/info.json @@ -12,4 +12,4 @@ ], "requirements": [], "hidden": false -} \ No newline at end of file +} diff --git a/reacticket/reacticket.py b/reacticket/reacticket.py index ef93de89..4c39f7bb 100644 --- a/reacticket/reacticket.py +++ b/reacticket/reacticket.py @@ -222,9 +222,7 @@ async def on_member_remove(self, member: discord.Member): ticket["assigned"], "mention", "Unknown moderator" ) ) - embed.add_field( - name="Assigned moderator", value=moderator, - ) + embed.add_field(name="Assigned moderator", value=moderator) await reporting_channel.send(embed=embed) else: message = ( diff --git a/requirements.txt b/requirements.txt index 3cd6f9ec..25318340 100644 --- a/requirements.txt +++ b/requirements.txt @@ -5,4 +5,4 @@ bs4 matplotlib colour prettytable -fuzzywuzzy \ No newline at end of file +fuzzywuzzy diff --git a/scanner/__init__.py b/scanner/__init__.py index fc3a1748..c63972b4 100644 --- a/scanner/__init__.py +++ b/scanner/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Scanner(bot)) +async def setup(bot): + await bot.add_cog(Scanner(bot)) diff --git a/scanner/info.json b/scanner/info.json index a2bc3472..41ee0531 100644 --- a/scanner/info.json +++ b/scanner/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog. All settings are disabled by default. Run `[p]scanner settings`.", - "name" : "scanner", - "short" : "Detects images being sent and checks whether they are inappropriate based on the set filters.", - "description" : "This cog will send a report to a channel with details of an image violating the set conditions, and will auto delete the message if set to.", - "tags" : ["tools"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog. All settings are disabled by default. Run `[p]scanner settings`.", + "name": "scanner", + "short": "Detects images being sent and checks whether they are inappropriate based on the set filters.", + "description": "This cog will send a report to a channel with details of an image violating the set conditions, and will auto delete the message if set to.", + "tags": [ + "tools" + ], + "requirements": [], + "hidden": false +} diff --git a/scanner/scanner.py b/scanner/scanner.py index 0e0cbfe2..71e4e8ba 100644 --- a/scanner/scanner.py +++ b/scanner/scanner.py @@ -30,7 +30,7 @@ import aiohttp import discord -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.utils.chat_formatting import humanize_list, inline URL = "https://api.sightengine.com/1.0/check.json" @@ -350,7 +350,7 @@ async def on_message(self, message): "".join(traceback.format_exception(type(error), error, error.__traceback__)) ) - @checks.admin_or_permissions(manage_messages=True) + @commands.admin_or_permissions(manage_messages=True) @commands.group() async def scanner(self, ctx): """Group command for changing scanner's settings.""" @@ -414,7 +414,7 @@ async def pingrole(self, ctx, *, role: discord.Role = None): await ctx.send("No roles are set for ping right now.") return e = discord.Embed( - title="The following roles are pinged when a report comes in.", description="", + title="The following roles are pinged when a report comes in.", description="" ) for r in roles: ro = ctx.guild.get_role(r) @@ -426,7 +426,7 @@ async def pingrole(self, ctx, *, role: discord.Role = None): await self.conf.guild(ctx.guild).roles.set(new) await ctx.send(embed=e) - @checks.is_owner() + @commands.is_owner() @scanner.command() async def creds(self, ctx, user, secret): """Set the API user and API secret to use with requests from sightengine.com.""" @@ -594,7 +594,8 @@ async def wad(self, ctx, yes_or_no: bool): async def offensive(self, ctx, yes_or_no: bool): """Set whether or not to check for offensive content in images. - Offensive content includes content such as middle fingers, offensive flags or offensive groups of people.""" + Offensive content includes content such as middle fingers, offensive flags or offensive groups of people. + """ await self.conf.guild(ctx.guild).offensive.set(yes_or_no) if yes_or_no: await ctx.send("Messages will now be reported if they violate the offensive rule.") @@ -637,8 +638,9 @@ async def checks_command(self, ctx): @checks_command.command(name="add") async def checks_add(self, ctx, *checks: str): """Adds checks to the Text Moderation check. - - Must be `sexual`, `insult`, `disciminatory`, `innapropriate`, `other_profanity`, `email`, `ipv4`, `ipv6`, `phone_number_us`, `phone_number_uk`, `phone_number_fr` or `ssn`.""" + + Must be `sexual`, `insult`, `disciminatory`, `innapropriate`, `other_profanity`, `email`, `ipv4`, `ipv6`, `phone_number_us`, `phone_number_uk`, `phone_number_fr` or `ssn`. + """ if not checks: return await ctx.send_help() data = await self.conf.guild(ctx.guild).textmoderation() @@ -723,8 +725,9 @@ async def mm_checks_command(self, ctx): @mm_checks_command.command(name="add") async def mm_checks_add(self, ctx, *checks: str): """Adds checks to the Message Moderation check. - - Must be `sexual`, `insult`, `disciminatory`, `innapropriate`, `other_profanity`, `email`, `ipv4`, `ipv6`, `phone_number_us`, `phone_number_uk`, `phone_number_fr` or `ssn`.""" + + Must be `sexual`, `insult`, `disciminatory`, `innapropriate`, `other_profanity`, `email`, `ipv4`, `ipv6`, `phone_number_us`, `phone_number_uk`, `phone_number_fr` or `ssn`. + """ if not checks: return await ctx.send_help() data = await self.conf.guild(ctx.guild).rawtextmoderation() @@ -771,7 +774,7 @@ async def mm_checks_clear(self, ctx): data["checks"] = [] await ctx.send("Message moderation check update successful") - @checks.is_owner() + @commands.is_owner() @mm.command(name="enable") async def messagemoderation_enable(self, ctx, yes_or_no: bool): """Set whether or not to check for Message Mderation.""" diff --git a/simon/info.json b/simon/info.json index da938727..e8977ba6 100644 --- a/simon/info.json +++ b/simon/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.\n\n***WARNING***: This cog relies heavily on sending messages, editing emojis and messages and deleting messages. It may use up the bot's rate limits while in use.", - "name" : "simon", - "short" : "Allows you to play Simon inside of Discord!\nWarning! This cog uses a major portion of the bot's rate limits.", - "description" : "This cog allows a Discord User to play the game Simon inside of a text channel.\nWarning! This cog uses a major portion of the bot's rate limits. This may prevent the bot from sending messages, adding emojis or deleting messages in specific peroids of time.", - "tags" : ["fun"], - "requirements" : [], - "hidden" : true -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.\n\n***WARNING***: This cog relies heavily on sending messages, editing emojis and messages and deleting messages. It may use up the bot's rate limits while in use.", + "name": "simon", + "short": "Allows you to play Simon inside of Discord!\nWarning! This cog uses a major portion of the bot's rate limits.", + "description": "This cog allows a Discord User to play the game Simon inside of a text channel.\nWarning! This cog uses a major portion of the bot's rate limits. This may prevent the bot from sending messages, adding emojis or deleting messages in specific peroids of time.", + "tags": [ + "fun" + ], + "requirements": [], + "hidden": true +} diff --git a/simon/simon.py b/simon/simon.py index 123ca637..b67b5236 100644 --- a/simon/simon.py +++ b/simon/simon.py @@ -26,14 +26,15 @@ import random import discord -from redbot.core import checks, commands +from redbot.core import commands class Simon(commands.Cog): """Play Simon, and guess the write number sequence! - + WARNING: - This cog sends a lot of messages, edits emojis and edits messages. It may use up rate limits heavily.""" + This cog sends a lot of messages, edits emojis and edits messages. It may use up rate limits heavily. + """ def __init__(self, bot): self.bot = bot @@ -44,7 +45,7 @@ async def red_delete_data_for_user(self, **kwargs): """This cog does not store user data""" return - @checks.bot_has_permissions(add_reactions=True) + @commands.bot_has_permissions(add_reactions=True) @commands.command() async def simon(self, ctx): """Start a game of Simon.""" diff --git a/sw/__init__.py b/sw/__init__.py index a2297f86..12cfd900 100644 --- a/sw/__init__.py +++ b/sw/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(SW(bot)) +async def setup(bot): + await bot.add_cog(SW(bot)) diff --git a/sw/info.json b/sw/info.json index d5b23066..b53314c6 100644 --- a/sw/info.json +++ b/sw/info.json @@ -1,9 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "sw", - "short" : "Get information about a bunch of different things in Star Wars.", - "description" : "Get information about a bunch of different things in Star Wars.", - "tags" : ["info", "fun"], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "sw", + "short": "Get information about a bunch of different things in Star Wars.", + "description": "Get information about a bunch of different things in Star Wars.", + "tags": [ + "info", + "fun" + ], + "hidden": false +} diff --git a/sw/sw.py b/sw/sw.py index 97e9b2e5..4de833c5 100644 --- a/sw/sw.py +++ b/sw/sw.py @@ -27,7 +27,7 @@ import aiohttp import discord -from redbot.core import checks, commands +from redbot.core import commands from redbot.core.utils.menus import DEFAULT_CONTROLS, menu from .image import ( @@ -62,7 +62,7 @@ async def red_delete_data_for_user(self, **kwargs): """This cog does not store user data""" return - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @commands.group(name="swapi", aliases=["starwars"]) async def starwars(self, ctx): """Group command for interacting with the Star Wars API""" @@ -104,7 +104,7 @@ async def person(self, ctx, person_id: Union[int, str]): homeworld = await self.session.get(person["homeworld"]) homeworld = json.loads(await homeworld.text()) embed.add_field( - name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}", + name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}" ) films = [] for film in person["films"]: @@ -119,7 +119,7 @@ async def person(self, ctx, person_id: Union[int, str]): species = await self.session.get(person["species"][0]) species = json.loads(await species.text()) embed.add_field( - name="Species", value=f"Name: {species['name']}; ID: {str(species_num)}", + name="Species", value=f"Name: {species['name']}; ID: {str(species_num)}" ) else: embed.add_field(name="Species", value="Name: Unknown") @@ -150,7 +150,7 @@ async def person(self, ctx, person_id: Union[int, str]): person = json.loads(await response.text()) name = person["results"][0]["name"] embed = discord.Embed( - title=f"Person: {name}", description=HUMANDESCRIPTION[name], color=0x32CD32, + title=f"Person: {name}", description=HUMANDESCRIPTION[name], color=0x32CD32 ) for key, value in person["results"][0].items(): if key in [ @@ -171,7 +171,7 @@ async def person(self, ctx, person_id: Union[int, str]): homeworld = await self.session.get(person["results"][0]["homeworld"]) homeworld = json.loads(await homeworld.text()) embed.add_field( - name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}", + name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}" ) films = [] for film in person["results"][0]["films"]: @@ -186,7 +186,7 @@ async def person(self, ctx, person_id: Union[int, str]): species = await self.session.get(person["species"][0]) species = json.loads(await species.text()) embed.add_field( - name="Species", value=f"Name: {species['name']}; ID: {str(species_num)}", + name="Species", value=f"Name: {species['name']}; ID: {str(species_num)}" ) else: embed.add_field(name="Species", value="Name: Unknown") @@ -265,7 +265,7 @@ async def planet(self, ctx, planet_id: Union[int, str]): planet = json.loads(await response.text()) name = planet["results"][0]["name"] embed = discord.Embed( - title=f"Planet: {name}", description=PLANETDESCRIPTION[name], color=0x800080, + title=f"Planet: {name}", description=PLANETDESCRIPTION[name], color=0x800080 ) for key, value in planet["results"][0].items(): if key in [ @@ -569,7 +569,7 @@ async def vehicle(self, ctx, vehicle_id: Union[int, str]): vehicle = json.loads(await response.text()) name = vehicle["results"][0]["name"] embed = discord.Embed( - title=f"Vehicle: {name}", description=VEHICLEDESCRIPTION[name], color=0x228B22, + title=f"Vehicle: {name}", description=VEHICLEDESCRIPTION[name], color=0x228B22 ) for key, value in vehicle["results"][0].items(): if key in ["name", "films", "edited", "created", "url", "pilots"]: @@ -628,7 +628,7 @@ async def species(self, ctx, species_id: Union[int, str]): homeworld = await self.session.get(species["homeworld"]) homeworld = json.loads(await homeworld.text()) embed.add_field( - name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}", + name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}" ) objects = [] for entry in species["films"]: @@ -657,7 +657,7 @@ async def species(self, ctx, species_id: Union[int, str]): species = json.loads(await response.text()) name = species["results"][0]["name"] embed = discord.Embed( - title=f"Species: {name}", description=SPECIESDESCRIPTION[name], color=0xD2B48C, + title=f"Species: {name}", description=SPECIESDESCRIPTION[name], color=0xD2B48C ) embed.add_field(name="ID:", value=str(species_id)) for key, value in species["results"][0].items(): @@ -677,7 +677,7 @@ async def species(self, ctx, species_id: Union[int, str]): homeworld = await self.session.get(species["results"][0]["homeworld"]) homeworld = json.loads(await homeworld.text()) embed.add_field( - name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}", + name="Homeworld", value=f"Name: {homeworld['name']}; ID: {str(homeworld_num)}" ) objects = [] for entry in species["results"][0]["films"]: diff --git a/targeter/__init__.py b/targeter/__init__.py index d076d318..54387e92 100644 --- a/targeter/__init__.py +++ b/targeter/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Targeter(bot)) +async def setup(bot): + await bot.add_cog(Targeter(bot)) diff --git a/targeter/info.json b/targeter/info.json index 2a799454..52b75ce8 100644 --- a/targeter/info.json +++ b/targeter/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "targeter", - "short" : "Targets users based upon the passed arguments", - "description" : "Returns a list of members in the current guild that meet the passed arguments. Commands can take long times based upon the amount of members in the guild.", - "tags" : ["tools"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "targeter", + "short": "Targets users based upon the passed arguments", + "description": "Returns a list of members in the current guild that meet the passed arguments. Commands can take long times based upon the amount of members in the guild.", + "tags": [ + "tools" + ], + "requirements": [], + "hidden": false +} diff --git a/targeter/targeter.py b/targeter/targeter.py index 72475ece..a41b3f8f 100644 --- a/targeter/targeter.py +++ b/targeter/targeter.py @@ -31,7 +31,7 @@ import aiohttp import discord from dateutil.parser import parse -from redbot.core import checks, commands +from redbot.core import commands from redbot.core.commands import BadArgument, Converter, RoleConverter from redbot.core.utils.chat_formatting import humanize_list, pagify from redbot.core.utils.menus import DEFAULT_CONTROLS, menu @@ -69,7 +69,7 @@ "view_audit_log", ] -# Large pieces of the argument parser is taken from Sinbad's cogs. I based mine off of https://github.com/mikeshardmind/SinbadCogs/blob/v3/scheduler/converters.py#L23 +# Large pieces of the argument parser is taken from Sinbad's cogs. I based mine off of https://github.com/mikeshardmind/SinbadCogs/blob/d59fd7bc69833dc24f9e74ec59e635ffe593d43f/scheduler/converters.py#L23 class NoExitParser(argparse.ArgumentParser): @@ -731,7 +731,7 @@ async def args_to_list(self, ctx: commands.Context, args: str): matched = await self.bot.loop.run_in_executor(None, compact) return matched - @checks.bot_has_permissions(embed_links=True) + @commands.bot_has_permissions(embed_links=True) @commands.guild_only() @commands.group(invoke_without_command=True) async def target(self, ctx, *, args: Args): @@ -785,7 +785,7 @@ async def target(self, ctx, *, args: Args): return else: embed = discord.Embed( - title="Targeting complete", description=f"Found no matches.", color=0xFF0000, + title="Targeting complete", description=f"Found no matches.", color=0xFF0000 ) m = False if not m: @@ -802,11 +802,11 @@ async def _help(self, ctx): desc = ( "`--nick ` - Users must have one of the passed nicks in their nickname. If they don't have a nickname, they will instantly be excluded.\n" "`--user ` - Users must have one of the passed usernames in their real username. This will not look at nicknames.\n" - "`--name ` - Users must have one of the passed names in their username, and if they don't have one, their username.\n" + "`--name ` - Users must have one of the passed names in their nickname, and if they don't have one, their username.\n" "\n" "`--not-nick ` - Users must not have one of the passed nicks in their nickname. If they don't have a nickname, they will instantly be excluded.\n" "`--not-user ` - Users must not have one of the passed usernames in their real username. This will not look at nicknames.\n" - "`--not-name ` - Users must not have one of the passed names in their username, and if they don't have one, their username.\n" + "`--not-name ` - Users must not have one of the passed names in their nickname, and if they don't have one, their username.\n" "\n" "`--a-nick` - Users must have a nickname in the server.\n" "`--no-nick` - Users cannot have a nickname in the server." @@ -877,7 +877,7 @@ async def _help(self, ctx): desc = ( "`--format` - How to display results. At the moment, must be `page` for posting on a website, or `menu` for showing the results in Discord.\n" "\n" - "If at any time you need to include quotes at the beginning or ending of something (such as a nickname or a role), include a slash (\) right before it." + "If at any time you need to include quotes at the beginning or ending of something (such as a nickname or a role), include a slash (\\) right before it." ) special.description = desc special.set_footer(text="Target Arguments - Special Notes; Page 6/6") diff --git a/twenty/__init__.py b/twenty/__init__.py index a9b4420c..e9bcfdb3 100644 --- a/twenty/__init__.py +++ b/twenty/__init__.py @@ -5,5 +5,5 @@ ) -def setup(bot): - bot.add_cog(Twenty(bot)) +async def setup(bot): + await bot.add_cog(Twenty(bot)) diff --git a/twenty/info.json b/twenty/info.json index cfa2fd14..2a0327e5 100644 --- a/twenty/info.json +++ b/twenty/info.json @@ -1,10 +1,14 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "twenty", - "short" : "Allows you to play 2048 inside of Discord!", - "description" : "This cog allows a Discord User to play 2048 inside of a text channel.", - "tags" : ["fun"], - "requirements" : [], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "twenty", + "short": "Allows you to play 2048 inside of Discord!", + "description": "This cog allows a Discord User to play 2048 inside of a text channel.", + "tags": [ + "fun" + ], + "requirements": [], + "hidden": false +} diff --git a/twenty/twenty.py b/twenty/twenty.py index 0f6d2ce4..4c22eca6 100644 --- a/twenty/twenty.py +++ b/twenty/twenty.py @@ -27,7 +27,7 @@ from copy import deepcopy as dc import discord -from redbot.core import checks, commands +from redbot.core import commands class Twenty(commands.Cog): @@ -42,7 +42,7 @@ async def red_delete_data_for_user(self, **kwargs): """This cog does not store user data""" return - @checks.bot_has_permissions(add_reactions=True) + @commands.bot_has_permissions(add_reactions=True) @commands.command() async def twenty(self, ctx): """Starts a 2048 game inside of Discord.""" diff --git a/updatechecker/__init__.py b/updatechecker/__init__.py index 0af816fa..a6e91a47 100644 --- a/updatechecker/__init__.py +++ b/updatechecker/__init__.py @@ -7,4 +7,4 @@ async def setup(bot): cog = UpdateChecker(bot) - bot.add_cog(cog) + await bot.add_cog(cog) diff --git a/updatechecker/info.json b/updatechecker/info.json index 977aeb88..5315ca7f 100644 --- a/updatechecker/info.json +++ b/updatechecker/info.json @@ -1,10 +1,16 @@ { - "author" : ["Neuro Assassin"], - "install_msg" : "Thank you for downloading this cog.", - "name" : "updatechecker", - "short" : "Notifies you when an update for a repo is available.", - "description" : "This cog will tell when there is an update available for a repository you have added for your bot, and, depending on settings, will auto update or will just notify you.", - "tags" : ["tools"], - "requirements" : ["feedparser"], - "hidden" : false -} \ No newline at end of file + "author": [ + "Neuro Assassin" + ], + "install_msg": "Thank you for downloading this cog.", + "name": "updatechecker", + "short": "Notifies you when an update for a repo is available.", + "description": "This cog will tell when there is an update available for a repository you have added for your bot, and, depending on settings, will auto update or will just notify you.", + "tags": [ + "tools" + ], + "requirements": [ + "feedparser" + ], + "hidden": false +} diff --git a/updatechecker/updatechecker.py b/updatechecker/updatechecker.py index f9fa2718..d369aa39 100644 --- a/updatechecker/updatechecker.py +++ b/updatechecker/updatechecker.py @@ -37,7 +37,7 @@ import aiohttp import discord from redbot.cogs.downloader.repo_manager import Repo -from redbot.core import Config, checks, commands +from redbot.core import Config, commands from redbot.core.utils.chat_formatting import humanize_list, inline import feedparser @@ -86,10 +86,22 @@ async def bg_task(self): use_embed = data["embed"] whitelist = data["whitelist"] blacklist = data["blacklist"] - if channel == 0: - channel = (await self.bot.application_info()).owner - else: + if channel: channel = self.bot.get_channel(channel) + if channel is None: + await self.bot.send_to_owners( + "[Update Checker] It appears that I am no longer allowed to send messages to the designated update channel. " + "From now on, it will DM you." + ) + await self.conf.gochannel.set(0) + send = self.bot.send_to_owners + else: + use_embed = ( + use_embed and channel.permissions_for(channel.guild.me).embed_links + ) + send = channel.send + else: + send = self.bot.send_to_owners all_repos = cog._repo_manager.get_all_repo_names() for repo in all_repos: @@ -125,71 +137,46 @@ async def bg_task(self): and commit_saved != "--default--" ): if True: # KACHOW - try: - if use_embed and isinstance(channel, discord.User): - e = discord.Embed( - title="Update Checker", - description=f"Update available for repo: {repo.name}", - timestamp=datetime.utcnow(), - color=0x00FF00, - ) - e.add_field(name="URL", value=repo.url) - e.add_field(name="Branch", value=repo.branch) - e.add_field(name="Commit", value=cn) - e.add_field(name="Hash", value=hash) - e.set_thumbnail(url=image) - await channel.send(embed=e) - elif ( - use_embed - and isinstance(channel, discord.TextChannel) - and channel.permissions_for(channel.guild.me).embed_links - ): - e = discord.Embed( - title="Update Checker", - description=f"Update available for repo: {repo.name}", - timestamp=datetime.utcnow(), - color=0x00FF00, - ) - e.add_field(name="URL", value=repo.url) - e.add_field(name="Branch", value=repo.branch) - e.add_field(name="Commit", value=cn) - e.add_field(name="Hash", value=hash) - e.set_thumbnail(url=image) - await channel.send(embed=e) - else: - e = ( - "```css\n" - "[Update Checker]" - "``````css\n" - f" Repo: {repo.name}\n" - f" URL: {repo.url}\n" - f" Commit: {cn}\n" - f" Hash: {commit}\n" - f" Time: {datetime.utcnow()}" - "```" - ) - await channel.send(e) - except AttributeError: - owner = (await self.bot.application_info()).owner - await owner.send( - "[Update Checker] It appears that the channel for this cog has been deleted. From now on, it will DM you." + if use_embed: + e = discord.Embed( + title="Update Checker", + description=f"Update available for repo: {repo.name}", + timestamp=datetime.utcnow(), + color=0x00FF00, ) - if isinstance(e, discord.Embed): - await owner.send(embed=e) + e.add_field(name="URL", value=repo.url) + e.add_field(name="Branch", value=repo.branch) + e.add_field(name="Commit", value=cn) + e.add_field(name="Hash", value=hash) + e.set_thumbnail(url=image) + else: + e = ( + "```css\n" + "[Update Checker]" + "``````css\n" + f" Repo: {repo.name}\n" + f" URL: {repo.url}\n" + f" Commit: {cn}\n" + f" Hash: {commit}\n" + f" Time: {datetime.utcnow()}" + "```" + ) + try: + if use_embed: + await send(embed=e) else: - await owner.send(e) - channel = owner - await self.conf.gochannel.set(0) - except discord.errors.Forbidden: - owner = (await self.bot.application_info()).owner - await owner.send( - "[Update Checker] It appears that I am no longer allowed to send messages to the designated update channel. From now on, it will DM you." + await send(e) + except discord.Forbidden: + # send_to_owners suppresses Forbidden, logging it to console. + # As a result, this will only happen if a channel was set. + await self.bot.send_to_owners( + "[Update Checker] It appears that I am no longer allowed to send messages to the designated update channel. " + "From now on, it will DM you." ) - if isinstance(e, discord.Embed): - await owner.send(embed=e) + if use_embed: + await self.bot.send_to_owners(embed=e) else: - await owner.send(e) - channel = owner + await self.bot.send_to_owners(e) await self.conf.gochannel.set(0) else: try: @@ -264,13 +251,13 @@ async def fetch_feed(self, url: str): return None return ret - @checks.is_owner() + @commands.is_owner() @commands.group(name="cogupdater", aliases=["cu"]) async def update(self, ctx): """Group command for controlling the update checker cog.""" pass - @checks.is_owner() + @commands.is_owner() @update.command() async def auto(self, ctx): """Changes automatic cog updates to the opposite setting.""" @@ -284,12 +271,15 @@ async def auto(self, ctx): "This command is disabled for the time being. Cog updates will not run automatically, however notifications will still send." ) - @checks.is_owner() + @commands.is_owner() @update.command() async def channel(self, ctx, channel: discord.TextChannel = None): - """Sets a channel for update messages to go to. + """ + Sets a channel for update messages to go to. - If argument is not supplied, it will be sent to the bot owner's DMs. By default, goes to owner DMs.""" + If argument is not supplied, it will be sent to the default notifications channel(s) specified in `[p]set ownernotifications`. + By default, this goes to owner DMs. + """ if channel: await self.conf.gochannel.set(channel.id) await ctx.send(f"Update messages will now be sent to {channel.mention}") @@ -297,12 +287,13 @@ async def channel(self, ctx, channel: discord.TextChannel = None): await self.conf.gochannel.set(0) await ctx.send("Update messages will now be DMed to you.") - @checks.is_owner() + @commands.is_owner() @update.command() async def settings(self, ctx): """See settings for the Update Checker cog. - Right now, this shows whether the bot updates cogs automatically and what channel logs are sent to.""" + Right now, this shows whether the bot updates cogs automatically and what channel logs are sent to. + """ auto = await self.conf.auto() channel = await self.conf.gochannel() embed = await self.conf.embed() @@ -336,7 +327,7 @@ async def settings(self, ctx): ) await ctx.send(message) - @checks.is_owner() + @commands.is_owner() @update.command() async def embed(self, ctx): """Toggles whether to use embeds or colorful codeblock messages when sending an update.""" @@ -345,7 +336,7 @@ async def embed(self, ctx): word = "disabled" if c else "enabled" await ctx.send(f"Embeds are now {word}") - @checks.is_owner() + @commands.is_owner() @update.group(name="list") async def whiteblacklist(self, ctx): """Whitelist/blacklist certain repositories from which to receive updates.""" @@ -423,7 +414,7 @@ async def blacklistclear(self, ctx): await self.conf.blacklist.set([]) await ctx.send("Blacklist update successful") - @checks.is_owner() + @commands.is_owner() @update.group(name="task") async def _group_update_task(self, ctx): """View the status of the task (the one checking for updates)."""