aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar wookie184 <[email protected]>2021-10-03 13:33:52 +0100
committerGravatar GitHub <[email protected]>2021-10-03 13:33:52 +0100
commit3e31c70ab0627cee2c59d265804c967171c40cee (patch)
tree6c27429f561d8ce2e4e0bea379124f51d6050b50
parentHackto issue finder: make d.py timestamp naive (diff)
parent`.quack` (#849) (diff)
Merge branch 'main' into bug/875/emoji-offet-naive
-rw-r--r--.gitpod.yml5
-rwxr-xr-xREADME.md1
-rw-r--r--bot/constants.py3
-rw-r--r--bot/exts/core/extensions.py2
-rw-r--r--bot/exts/fun/quack.py75
-rw-r--r--bot/exts/utilities/bookmark.py5
6 files changed, 86 insertions, 5 deletions
diff --git a/.gitpod.yml b/.gitpod.yml
new file mode 100644
index 00000000..a10e6e26
--- /dev/null
+++ b/.gitpod.yml
@@ -0,0 +1,5 @@
+tasks:
+ - name: "Python Environment"
+ before: "pyenv install 3.9.6 && pyenv global 3.9.6"
+ init: "pip install poetry && export PIP_USER=false"
+ command: "poetry install && poetry run pre-commit install"
diff --git a/README.md b/README.md
index dd8301dc..2e2b7aec 100755
--- a/README.md
+++ b/README.md
@@ -4,6 +4,7 @@
[![Lint Badge][1]][2]
[![Build Badge][3]][4]
[![License](https://img.shields.io/badge/license-MIT-green)](LICENSE)
+[![Open in Gitpod](https://img.shields.io/badge/Gitpod-ready--to--code-908a85?logo=gitpod)](https://gitpod.io/#/github.com/python-discord/sir-lancebot)
![Header](sir-lancebot-logo.png)
diff --git a/bot/constants.py b/bot/constants.py
index 2313bfdb..6e45632f 100644
--- a/bot/constants.py
+++ b/bot/constants.py
@@ -280,11 +280,12 @@ if Client.month_override is not None:
class Roles(NamedTuple):
+ owner = 267627879762755584
admin = int(environ.get("BOT_ADMIN_ROLE_ID", 267628507062992896))
moderator = 267629731250176001
- owner = 267627879762755584
helpers = int(environ.get("ROLE_HELPERS", 267630620367257601))
core_developers = 587606783669829632
+ everyone = int(environ.get("BOT_GUILD", 267624335836053506))
class Tokens(NamedTuple):
diff --git a/bot/exts/core/extensions.py b/bot/exts/core/extensions.py
index 424bacac..dbb9e069 100644
--- a/bot/exts/core/extensions.py
+++ b/bot/exts/core/extensions.py
@@ -18,7 +18,7 @@ from bot.utils.pagination import LinePaginator
log = logging.getLogger(__name__)
-UNLOAD_BLACKLIST = {f"{exts.__name__}.utils.extensions"}
+UNLOAD_BLACKLIST = {f"{exts.__name__}.core.extensions"}
BASE_PATH_LEN = len(exts.__name__.split("."))
diff --git a/bot/exts/fun/quack.py b/bot/exts/fun/quack.py
new file mode 100644
index 00000000..0c228aed
--- /dev/null
+++ b/bot/exts/fun/quack.py
@@ -0,0 +1,75 @@
+import logging
+import random
+from typing import Literal, Optional
+
+import discord
+from discord.ext import commands
+
+from bot.bot import Bot
+from bot.constants import Colours, NEGATIVE_REPLIES
+
+API_URL = 'https://quackstack.pythondiscord.com'
+
+log = logging.getLogger(__name__)
+
+
+class Quackstack(commands.Cog):
+ """Cog used for wrapping Quackstack."""
+
+ def __init__(self, bot: Bot):
+ self.bot = bot
+
+ @commands.command()
+ async def quack(
+ self,
+ ctx: commands.Context,
+ ducktype: Literal["duck", "manduck"] = "duck",
+ *,
+ seed: Optional[str] = None
+ ) -> None:
+ """
+ Use the Quackstack API to generate a random duck.
+
+ If a seed is provided, a duck is generated based on the given seed.
+ Either "duck" or "manduck" can be provided to change the duck type generated.
+ """
+ ducktype = ducktype.lower()
+ quackstack_url = f"{API_URL}/{ducktype}"
+ params = {}
+ if seed is not None:
+ try:
+ seed = int(seed)
+ except ValueError:
+ # We just need to turn the string into an integer any way possible
+ seed = int.from_bytes(seed.encode(), "big")
+ params["seed"] = seed
+
+ async with self.bot.http_session.get(quackstack_url, params=params) as response:
+ error_embed = discord.Embed(
+ title=random.choice(NEGATIVE_REPLIES),
+ description="The request failed. Please try again later.",
+ color=Colours.soft_red,
+ )
+ if response.status != 200:
+ log.error(f"Response to Quackstack returned code {response.status}")
+ await ctx.send(embed=error_embed)
+ return
+
+ data = await response.json()
+ file = data["file"]
+
+ embed = discord.Embed(
+ title=f"Quack! Here's a {ducktype} for you.",
+ description=f"A {ducktype} from Quackstack.",
+ color=Colours.grass_green,
+ url=f"{API_URL}/docs"
+ )
+
+ embed.set_image(url=API_URL + file)
+
+ await ctx.send(embed=embed)
+
+
+def setup(bot: Bot) -> None:
+ """Loads the Quack cog."""
+ bot.add_cog(Quackstack(bot))
diff --git a/bot/exts/utilities/bookmark.py b/bot/exts/utilities/bookmark.py
index a91ef1c0..39d65168 100644
--- a/bot/exts/utilities/bookmark.py
+++ b/bot/exts/utilities/bookmark.py
@@ -7,7 +7,7 @@ import discord
from discord.ext import commands
from bot.bot import Bot
-from bot.constants import Categories, Colours, ERROR_REPLIES, Icons, WHITELISTED_CHANNELS
+from bot.constants import Colours, ERROR_REPLIES, Icons, Roles
from bot.utils.converters import WrappedMessageConverter
from bot.utils.decorators import whitelist_override
@@ -16,7 +16,6 @@ log = logging.getLogger(__name__)
# Number of seconds to wait for other users to bookmark the same message
TIMEOUT = 120
BOOKMARK_EMOJI = "📌"
-WHITELISTED_CATEGORIES = (Categories.help_in_use,)
class Bookmark(commands.Cog):
@@ -87,8 +86,8 @@ class Bookmark(commands.Cog):
await message.add_reaction(BOOKMARK_EMOJI)
return message
- @whitelist_override(channels=WHITELISTED_CHANNELS, categories=WHITELISTED_CATEGORIES)
@commands.command(name="bookmark", aliases=("bm", "pin"))
+ @whitelist_override(roles=(Roles.everyone,))
async def bookmark(
self,
ctx: commands.Context,