diff options
5 files changed, 25 insertions, 18 deletions
diff --git a/pydis_site/apps/content/resources/guides/python-guides/discord-embed-limits.md b/pydis_site/apps/content/resources/guides/python-guides/discord-embed-limits.md index ca97462b..b1385016 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/discord-embed-limits.md +++ b/pydis_site/apps/content/resources/guides/python-guides/discord-embed-limits.md @@ -11,11 +11,11 @@ If you plan on using embed responses for your bot you should know the limits of - A **field name/title** is limited to **256 character** and the **value of the field** is limited to **1024 characters** - Embed **footer** is limited to **2048 characters** - Embed **author name** is limited to **256 characters** -- The **total of characters** allowed in an embed is **6000** +- The **total characters** of all embeds in a single message is limited to **6000** +- A message is limited to **10 embeds** Now if you need to get over this limit (for example for a help command), you would need to use pagination. There are several ways to do that: -- A library called **[disputils](https://pypi.org/project/disputils)** - An experimental library made by the discord.py developer called **[discord-ext-menus](https://github.com/Rapptz/discord-ext-menus)** - Make your own setup using **[wait_for()](https://discordpy.readthedocs.io/en/stable/ext/commands/api.html#discord.ext.commands.Bot.wait_for)** and wait for a reaction to be added diff --git a/pydis_site/apps/content/resources/guides/python-guides/vps-services.md b/pydis_site/apps/content/resources/guides/python-guides/vps-services.md index b3405da4..9a4a28c9 100644 --- a/pydis_site/apps/content/resources/guides/python-guides/vps-services.md +++ b/pydis_site/apps/content/resources/guides/python-guides/vps-services.md @@ -42,17 +42,3 @@ While these may seem like nice and free services, it has a lot more caveats than - They use a shared IP for everything running on the service. This one is important - if someone is running a user bot on their service and gets banned, everyone on that IP will be banned. Including you. - -### Heroku -- Bots are not what the platform is designed for. Heroku is designed to provide web servers (like Django, Flask, etc). This is why they give you a domain name and open a port on their local emulator. - -- Heroku's environment is heavily containerized, making it significantly underpowered for a standard use case. - -- Heroku's environment is volatile. In order to handle the insane amount of users trying to use it for their own applications, Heroku will dispose your environment every time your application dies unless you pay. - -- Heroku has minimal system dependency control. If any of your Python requirements need C bindings (such as PyNaCl - binding to libsodium, or lxml binding to libxml), they are unlikely to function properly, if at all, in a native - environment. As such, you often need to resort to adding third-party buildpacks to facilitate otherwise normal - CPython extension functionality. (This is the reason why voice doesn't work natively on heroku) - -- Heroku only offers a limited amount of time on their free programme for your applications. If you exceed this limit, which you probably will, they'll shut down your application until your free credit resets. diff --git a/pydis_site/apps/resources/tests/test_views.py b/pydis_site/apps/resources/tests/test_views.py index a2a203ce..72c9ed95 100644 --- a/pydis_site/apps/resources/tests/test_views.py +++ b/pydis_site/apps/resources/tests/test_views.py @@ -27,3 +27,14 @@ class TestResourcesView(TestCase): url = reverse("resources:index", kwargs={"resource_type": "urinal-cake"}) response = self.client.get(url) self.assertEqual(response.status_code, 404) + + +class TestResourceFilterView(TestCase): + def test_resource_filter_response(self): + """Check that the filter endpoint returns JSON-formatted filters.""" + url = reverse('resources:filters') + response = self.client.get(url) + self.assertEqual(response.status_code, 200) + content = response.json() + self.assertIn('difficulty', content) + self.assertIsInstance(content['difficulty'], list) diff --git a/pydis_site/apps/resources/urls.py b/pydis_site/apps/resources/urls.py index cb33a9d7..3a10d108 100644 --- a/pydis_site/apps/resources/urls.py +++ b/pydis_site/apps/resources/urls.py @@ -1,11 +1,12 @@ from django_distill import distill_path -from pydis_site.apps.resources.views import ResourceView +from pydis_site.apps.resources.views import ResourceView, ResourceFilterView app_name = "resources" urlpatterns = [ # Using `distill_path` instead of `path` allows this to be available # in static preview builds. distill_path("", ResourceView.as_view(), name="index"), + distill_path("filters", ResourceFilterView.as_view(), name="filters"), distill_path("<resource_type>/", ResourceView.as_view(), name="index"), ] diff --git a/pydis_site/apps/resources/views.py b/pydis_site/apps/resources/views.py index 3632b2e2..6683299f 100644 --- a/pydis_site/apps/resources/views.py +++ b/pydis_site/apps/resources/views.py @@ -2,7 +2,7 @@ import json from django.apps import apps from django.core.handlers.wsgi import WSGIRequest -from django.http import HttpResponse, HttpResponseNotFound +from django.http import HttpResponse, HttpResponseNotFound, JsonResponse from django.shortcuts import render from django.views import View @@ -38,3 +38,12 @@ class ResourceView(View): "resource_type": resource_type, } ) + + +class ResourceFilterView(View): + """Exposes resource filters for the bot.""" + + def get(self, request: WSGIRequest) -> HttpResponse: + """Return resource filters as JSON.""" + app = apps.get_app_config(APP_NAME) + return JsonResponse(app.valid_filters) |