diff options
| -rw-r--r-- | bot/__main__.py | 1 | ||||
| -rw-r--r-- | bot/cogs/moderation.py | 4 | ||||
| -rw-r--r-- | bot/cogs/site.py | 98 | ||||
| -rw-r--r-- | bot/constants.py | 1 | ||||
| -rw-r--r-- | config-default.yml | 47 | 
5 files changed, 126 insertions, 25 deletions
| diff --git a/bot/__main__.py b/bot/__main__.py index a2c10476c..aa73e42bd 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -65,6 +65,7 @@ bot.load_extension("bot.cogs.information")  bot.load_extension("bot.cogs.moderation")  bot.load_extension("bot.cogs.off_topic_names")  bot.load_extension("bot.cogs.reddit") +bot.load_extension("bot.cogs.site")  bot.load_extension("bot.cogs.snakes")  bot.load_extension("bot.cogs.snekbox")  bot.load_extension("bot.cogs.tags") diff --git a/bot/cogs/moderation.py b/bot/cogs/moderation.py index b04887b3f..ee28a3600 100644 --- a/bot/cogs/moderation.py +++ b/bot/cogs/moderation.py @@ -172,7 +172,7 @@ class Moderation:          self.mod_log.ignore(Event.member_ban, user.id)          self.mod_log.ignore(Event.member_remove, user.id) -        await ctx.guild.ban(user, reason=reason) +        await ctx.guild.ban(user, reason=reason, delete_message_days=0)          if reason is None:              result_message = f":ok_hand: permanently banned {user.mention}." @@ -349,7 +349,7 @@ class Moderation:          self.mod_log.ignore(Event.member_ban, user.id)          self.mod_log.ignore(Event.member_remove, user.id)          guild: Guild = ctx.guild -        await guild.ban(user, reason=reason) +        await guild.ban(user, reason=reason, delete_message_days=0)          infraction_object = response_object["infraction"]          infraction_expiration = infraction_object["expires_at"] diff --git a/bot/cogs/site.py b/bot/cogs/site.py new file mode 100644 index 000000000..e5fd645fb --- /dev/null +++ b/bot/cogs/site.py @@ -0,0 +1,98 @@ +import logging + +from discord import Colour, Embed +from discord.ext.commands import Bot, Context, group + +from bot.constants import URLs + +log = logging.getLogger(__name__) + +INFO_URL = f"{URLs.site_schema}{URLs.site}/info" + + +class Site: +    """Commands for linking to different parts of the site.""" + +    def __init__(self, bot: Bot): +        self.bot = bot + +    @group(name="site", aliases=("s",), invoke_without_command=True) +    async def site_group(self, ctx): +        """Commands for getting info about our website.""" + +        await ctx.invoke(self.bot.get_command("help"), "site") + +    @site_group.command(name="home", aliases=("about",)) +    async def site_main(self, ctx: Context): +        """Info about the website itself.""" + +        url = f"{URLs.site_schema}{URLs.site}/" + +        embed = Embed(title="Python Discord website") +        embed.set_footer(text=url) +        embed.colour = Colour.blurple() +        embed.description = ( +            f"[Our official website]({url}) is an open-source community project " +            "created with Python and Flask. It contains information about the server " +            "itself, lets you sign up for upcoming events, has its own wiki, contains " +            "a list of valuable learning resources, and much more." +        ) + +        await ctx.send(embed=embed) + +    @site_group.command(name="resources") +    async def site_resources(self, ctx: Context): +        """Info about the site's Resources page.""" + +        url = f"{INFO_URL}/resources" + +        embed = Embed(title="Resources") +        embed.set_footer(text=url) +        embed.colour = Colour.blurple() +        embed.description = ( +            f"The [Resources page]({url}) on our website contains a " +            "list of hand-selected goodies that we regularly recommend " +            "to both beginners and experts." +        ) + +        await ctx.send(embed=embed) + +    @site_group.command(name="help") +    async def site_help(self, ctx: Context): +        """Info about the site's Getting Help page.""" + +        url = f"{INFO_URL}/help" + +        embed = Embed(title="Getting Help") +        embed.set_footer(text=url) +        embed.colour = Colour.blurple() +        embed.description = ( +            "Asking the right question about something that's new to you can sometimes be tricky. " +            f"To help with this, we've created a [guide to asking good questions]({url}) on our website. " +            "It contains everything you need to get the very best help from our community." +        ) + +        await ctx.send(embed=embed) + +    @site_group.command(name="faq") +    async def site_faq(self, ctx: Context): +        """Info about the site's FAQ page.""" + +        url = f"{INFO_URL}/faq" + +        embed = Embed(title="FAQ") +        embed.set_footer(text=url) +        embed.colour = Colour.blurple() +        embed.description = ( +            "As the largest Python community on Discord, we get hundreds of questions every day. " +            "Many of these questions have been asked before. We've compiled a list of the most " +            "frequently asked questions along with their answers, which can be found on " +            f"our [FAQ page]({url})." +        ) + +        await ctx.send(embed=embed) + + +def setup(bot): +    bot.add_cog(Site(bot)) +    log.info("Cog loaded: Site") diff --git a/bot/constants.py b/bot/constants.py index 5e1dc1e39..1e789ff3a 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -385,6 +385,7 @@ class URLs(metaclass=YAMLGetter):      gitlab_bot_repo: str      omdb: str      site: str +    site_api: str      site_facts_api: str      site_clean_api: str      site_clean_logs: str diff --git a/config-default.yml b/config-default.yml index fd0e33633..cfe456fbe 100644 --- a/config-default.yml +++ b/config-default.yml @@ -209,29 +209,30 @@ rabbitmq:  urls:      # PyDis site vars -    site:        &DOMAIN "api.pythondiscord.com" -    site_schema: &SCHEMA "https://" - -    site_bigbrother_api:                !JOIN [*SCHEMA, *DOMAIN, "/bot/bigbrother"] -    site_clean_api:                     !JOIN [*SCHEMA, *DOMAIN, "/bot/clean"] -    site_clean_logs:                    !JOIN [*SCHEMA, *DOMAIN, "/bot/clean_logs"] -    site_docs_api:                      !JOIN [*SCHEMA, *DOMAIN, "/bot/docs"] -    site_facts_api:                     !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_facts"] -    site_hiphopify_api:                 !JOIN [*SCHEMA, *DOMAIN, "/bot/hiphopify"] -    site_idioms_api:                    !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_idioms"] -    site_infractions:                   !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions"] -    site_infractions_user:              !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/user/{user_id}"] -    site_infractions_type:              !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/type/{infraction_type}"] -    site_infractions_by_id:             !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/id/{infraction_id}"] -    site_infractions_user_type_current: !JOIN [*SCHEMA, *DOMAIN, "/bot/infractions/user/{user_id}/{infraction_type}/current"] -    site_names_api:                     !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_names"] -    site_off_topic_names_api:           !JOIN [*SCHEMA, *DOMAIN, "/bot/off-topic-names"] -    site_quiz_api:                      !JOIN [*SCHEMA, *DOMAIN, "/bot/snake_quiz"] -    site_settings_api:                  !JOIN [*SCHEMA, *DOMAIN, "/bot/settings"] -    site_special_api:                   !JOIN [*SCHEMA, *DOMAIN, "/bot/special_snakes"] -    site_tags_api:                      !JOIN [*SCHEMA, *DOMAIN, "/bot/tags"] -    site_user_api:                      !JOIN [*SCHEMA, *DOMAIN, "/bot/users"] -    site_user_complete_api:             !JOIN [*SCHEMA, *DOMAIN, "/bot/users/complete"] +    site:        &DOMAIN       "pythondiscord.com" +    site_api:    &API    !JOIN ["api.", *DOMAIN] +    site_schema: &SCHEMA       "https://" + +    site_bigbrother_api:                !JOIN [*SCHEMA, *API, "/bot/bigbrother"] +    site_clean_api:                     !JOIN [*SCHEMA, *API, "/bot/clean"] +    site_clean_logs:                    !JOIN [*SCHEMA, *API, "/bot/clean_logs"] +    site_docs_api:                      !JOIN [*SCHEMA, *API, "/bot/docs"] +    site_facts_api:                     !JOIN [*SCHEMA, *API, "/bot/snake_facts"] +    site_hiphopify_api:                 !JOIN [*SCHEMA, *API, "/bot/hiphopify"] +    site_idioms_api:                    !JOIN [*SCHEMA, *API, "/bot/snake_idioms"] +    site_infractions:                   !JOIN [*SCHEMA, *API, "/bot/infractions"] +    site_infractions_user:              !JOIN [*SCHEMA, *API, "/bot/infractions/user/{user_id}"] +    site_infractions_type:              !JOIN [*SCHEMA, *API, "/bot/infractions/type/{infraction_type}"] +    site_infractions_by_id:             !JOIN [*SCHEMA, *API, "/bot/infractions/id/{infraction_id}"] +    site_infractions_user_type_current: !JOIN [*SCHEMA, *API, "/bot/infractions/user/{user_id}/{infraction_type}/current"] +    site_names_api:                     !JOIN [*SCHEMA, *API, "/bot/snake_names"] +    site_off_topic_names_api:           !JOIN [*SCHEMA, *API, "/bot/off-topic-names"] +    site_quiz_api:                      !JOIN [*SCHEMA, *API, "/bot/snake_quiz"] +    site_settings_api:                  !JOIN [*SCHEMA, *API, "/bot/settings"] +    site_special_api:                   !JOIN [*SCHEMA, *API, "/bot/special_snakes"] +    site_tags_api:                      !JOIN [*SCHEMA, *API, "/bot/tags"] +    site_user_api:                      !JOIN [*SCHEMA, *API, "/bot/users"] +    site_user_complete_api:             !JOIN [*SCHEMA, *API, "/bot/users/complete"]      # Env vars      deploy: !ENV "DEPLOY_URL" | 
