diff options
Diffstat (limited to 'bot')
| -rw-r--r-- | bot/__main__.py | 10 | ||||
| -rw-r--r-- | bot/bot.py | 4 | ||||
| -rw-r--r-- | bot/constants.py | 22 | ||||
| -rw-r--r-- | bot/exts/core/extensions.py | 4 | ||||
| -rw-r--r-- | bot/exts/core/help.py | 4 | ||||
| -rw-r--r-- | bot/exts/core/internal_eval/_internal_eval.py | 2 | ||||
| -rw-r--r-- | bot/exts/fun/fun.py | 4 | ||||
| -rw-r--r-- | bot/exts/fun/minesweeper.py | 6 | ||||
| -rw-r--r-- | bot/exts/fun/trivia_quiz.py | 4 | ||||
| -rw-r--r-- | bot/exts/holidays/halloween/spookynamerate.py | 20 | ||||
| -rw-r--r-- | bot/exts/holidays/pride/pride_leader.py | 2 | ||||
| -rw-r--r-- | bot/exts/utilities/cheatsheet.py | 6 | ||||
| -rw-r--r-- | bot/exts/utilities/logging.py | 2 | ||||
| -rw-r--r-- | bot/exts/utilities/wtf_python.py | 6 | ||||
| -rw-r--r-- | bot/utils/__init__.py | 6 | ||||
| -rw-r--r-- | bot/utils/checks.py | 2 | 
16 files changed, 54 insertions, 50 deletions
| diff --git a/bot/__main__.py b/bot/__main__.py index d39e93bf..970614ce 100644 --- a/bot/__main__.py +++ b/bot/__main__.py @@ -62,11 +62,11 @@ async def main() -> None:      async with aiohttp.ClientSession() as session:          bot.instance = Bot( -            guild_id=constants.Client.guild, +            guild_id=constants.Bot.guild,              http_session=session,              redis_session=await _create_redis_session(), -            command_prefix=commands.when_mentioned_or(constants.Client.prefix), -            activity=discord.Game(name=f"Commands: {constants.Client.prefix}help"), +            command_prefix=commands.when_mentioned_or(constants.Bot.prefix), +            activity=discord.Game(name=f"Commands: {constants.Bot.prefix}help"),              case_insensitive=True,              allowed_mentions=discord.AllowedMentions(everyone=False, roles=allowed_roles),              intents=intents, @@ -78,10 +78,10 @@ async def main() -> None:                  channels=constants.WHITELISTED_CHANNELS,                  roles=constants.STAFF_ROLES,              )) -            if constants.Client.in_ci: +            if constants.Bot.in_ci:                  await test_bot_in_ci(_bot)              else: -                await _bot.start(constants.Client.token) +                await _bot.start(constants.Bot.token)  asyncio.run(main()) @@ -23,12 +23,12 @@ class Bot(BotBase):      that the upload was successful. See the `mock_in_debug` decorator for further details.      """ -    name = constants.Client.name +    name = constants.Bot.name      @property      def member(self) -> Optional[discord.Member]:          """Retrieves the guild member object for the bot.""" -        guild = self.get_guild(constants.Client.guild) +        guild = self.get_guild(constants.Bot.guild)          if not guild:              return None          return guild.me diff --git a/bot/constants.py b/bot/constants.py index 4c657ff9..ee7ab6d8 100644 --- a/bot/constants.py +++ b/bot/constants.py @@ -10,7 +10,7 @@ __all__ = (      "Cats",      "Channels",      "Categories", -    "Client", +    "Bot",      "Logging",      "Colours",      "Emojis", @@ -102,17 +102,21 @@ Categories = _Categories()  CODEJAM_CATEGORY_NAME = "Code Jam"  # Name of the codejam team categories -class Client(NamedTuple): +class _Bot(EnvConfig): +    EnvConfig.Config.env_prefix = "bot_" +      name = "Sir Lancebot" -    guild = int(environ.get("BOT_GUILD", 267624335836053506)) -    prefix = environ.get("PREFIX", ".") -    token = environ.get("BOT_TOKEN") -    debug = environ.get("BOT_DEBUG", "true").lower() == "true" -    in_ci = environ.get("IN_CI", "false").lower() == "true" -    github_bot_repo = "https://github.com/python-discord/sir-lancebot" +    guild = 267624335836053506 +    prefix = "." +    token = "" +    debug = True +    in_ci = False +    github_repo = "https://github.com/python-discord/sir-lancebot"      # Override seasonal locks: 1 (January) to 12 (December) -    month_override = int(environ["MONTH_OVERRIDE"]) if "MONTH_OVERRIDE" in environ else None +    month_override: int | None = None + +Bot = _Bot()  class Logging(NamedTuple):      debug = Client.debug diff --git a/bot/exts/core/extensions.py b/bot/exts/core/extensions.py index 1d22cf37..3b1a1e8a 100644 --- a/bot/exts/core/extensions.py +++ b/bot/exts/core/extensions.py @@ -11,7 +11,7 @@ from pydis_core.utils._extensions import unqualify  from bot import exts  from bot.bot import Bot -from bot.constants import Client, Emojis, MODERATION_ROLES, Roles +from bot.constants import Bot, Emojis, MODERATION_ROLES, Roles  from bot.utils.checks import with_role_check  from bot.utils.pagination import LinePaginator @@ -155,7 +155,7 @@ class Extensions(commands.Cog):          embed = Embed(colour=Colour.og_blurple())          embed.set_author(              name="Extensions List", -            url=Client.github_bot_repo, +            url=Bot.github_repo,              icon_url=str(self.bot.user.display_avatar.url)          ) diff --git a/bot/exts/core/help.py b/bot/exts/core/help.py index 30deaff4..d031cafe 100644 --- a/bot/exts/core/help.py +++ b/bot/exts/core/help.py @@ -311,7 +311,7 @@ class HelpSession:          self._pages = paginator.pages      async def _add_command_signature(self, paginator: LinePaginator) -> None: -        prefix = constants.Client.prefix +        prefix = constants.Bot.prefix          signature = self._get_command_params(self.query)          paginator.add_line(f"**```\n{prefix}{signature}\n```**") @@ -405,7 +405,7 @@ class HelpSession:          if isinstance(self.query, commands.Command):              prefix = ""          else: -            prefix = constants.Client.prefix +            prefix = constants.Bot.prefix          signature = self._get_command_params(command)          info = f"{strikeout}**`{prefix}{signature}`**{strikeout}" diff --git a/bot/exts/core/internal_eval/_internal_eval.py b/bot/exts/core/internal_eval/_internal_eval.py index 2daf8ef9..7365effc 100644 --- a/bot/exts/core/internal_eval/_internal_eval.py +++ b/bot/exts/core/internal_eval/_internal_eval.py @@ -43,7 +43,7 @@ class InternalEval(commands.Cog):          self.bot = bot          self.locals = {} -        if Client.debug: +        if Bot.debug:              self.internal_group.add_check(commands.is_owner().predicate)      @staticmethod diff --git a/bot/exts/fun/fun.py b/bot/exts/fun/fun.py index 16279dd7..aa12b079 100644 --- a/bot/exts/fun/fun.py +++ b/bot/exts/fun/fun.py @@ -12,7 +12,7 @@ from discord.ext.commands import BadArgument, Cog, Context  from pydis_core.utils.commands import clean_text_or_reply  from bot.bot import Bot -from bot.constants import Client, Colours, Emojis +from bot.constants import Bot, Colours, Emojis  from bot.utils import helpers, messages  log = logging.getLogger(__name__) @@ -58,7 +58,7 @@ class Fun(Cog):              dice = " ".join(self._get_random_die() for _ in range(num_rolls))              await ctx.send(dice)          else: -            raise BadArgument(f"`{Client.prefix}roll` only supports between 1 and 6 rolls.") +            raise BadArgument(f"`{Bot.prefix}roll` only supports between 1 and 6 rolls.")      @commands.command(name="randomcase", aliases=("rcase", "randomcaps", "rcaps",))      async def randomcase_command(self, ctx: Context, *, text: str | None) -> None: diff --git a/bot/exts/fun/minesweeper.py b/bot/exts/fun/minesweeper.py index f16b1db2..cd1f6711 100644 --- a/bot/exts/fun/minesweeper.py +++ b/bot/exts/fun/minesweeper.py @@ -8,7 +8,7 @@ import discord  from discord.ext import commands  from bot.bot import Bot -from bot.constants import Client +from bot.constants import Bot  from bot.utils.converters import CoordinateConverter  from bot.utils.exceptions import UserNotPlayingError @@ -117,8 +117,8 @@ class Minesweeper(commands.Cog):          try:              await ctx.author.send( -                f"Play by typing: `{Client.prefix}ms reveal xy [xy]` or `{Client.prefix}ms flag xy [xy]` \n" -                f"Close the game with `{Client.prefix}ms end`\n" +                f"Play by typing: `{Bot.prefix}ms reveal xy [xy]` or `{Bot.prefix}ms flag xy [xy]` \n" +                f"Close the game with `{Bot.prefix}ms end`\n"              )          except discord.errors.Forbidden:              log.debug(f"{ctx.author.name} ({ctx.author.id}) has disabled DMs from server members.") diff --git a/bot/exts/fun/trivia_quiz.py b/bot/exts/fun/trivia_quiz.py index 31652374..546b796b 100644 --- a/bot/exts/fun/trivia_quiz.py +++ b/bot/exts/fun/trivia_quiz.py @@ -16,7 +16,7 @@ from discord.ext import commands, tasks  from rapidfuzz import fuzz  from bot.bot import Bot -from bot.constants import Client, Colours, MODERATION_ROLES, NEGATIVE_REPLIES +from bot.constants import Bot, Colours, MODERATION_ROLES, NEGATIVE_REPLIES  logger = logging.getLogger(__name__) @@ -332,7 +332,7 @@ class TriviaQuiz(commands.Cog):          if self.game_status[ctx.channel.id]:              await ctx.send(                  "Game is already running... " -                f"do `{Client.prefix}quiz stop`" +                f"do `{Bot.prefix}quiz stop`"              )              return diff --git a/bot/exts/holidays/halloween/spookynamerate.py b/bot/exts/holidays/halloween/spookynamerate.py index a76e5e12..fd3f4247 100644 --- a/bot/exts/holidays/halloween/spookynamerate.py +++ b/bot/exts/holidays/halloween/spookynamerate.py @@ -15,7 +15,7 @@ from discord.ext import tasks  from discord.ext.commands import Cog, Context, group  from bot.bot import Bot -from bot.constants import Channels, Client, Colours, Month +from bot.constants import Channels, Bot, Colours, Month  from bot.utils.decorators import InMonthCheckFailure  logger = getLogger(__name__) @@ -38,7 +38,7 @@ PING = "<@{id}>"  EMOJI_MESSAGE = "\n".join(f"- {emoji} {val}" for emoji, val in EMOJIS_VAL.items())  HELP_MESSAGE_DICT = {      "title": "Spooky Name Rate", -    "description": f"Help for the `{Client.prefix}spookynamerate` command", +    "description": f"Help for the `{Bot.prefix}spookynamerate` command",      "color": Colours.soft_orange,      "fields": [          { @@ -54,12 +54,12 @@ HELP_MESSAGE_DICT = {          },          {              "name": "How do I add my spookified name?", -            "value": f"Simply type `{Client.prefix}spookynamerate add my name`", +            "value": f"Simply type `{Bot.prefix}spookynamerate add my name`",              "inline": False,          },          {              "name": "How do I *delete* my spookified name?", -            "value": f"Simply type `{Client.prefix}spookynamerate delete`", +            "value": f"Simply type `{Bot.prefix}spookynamerate delete`",              "inline": False,          },      ], @@ -141,7 +141,7 @@ class SpookyNameRate(Cog):              if data["author"] == ctx.author.id:                  await ctx.send(                      "But you have already added an entry! Type " -                    f"`{Client.prefix}spookynamerate " +                    f"`{Bot.prefix}spookynamerate "                      "delete` to delete it, and then you can add it again"                  )                  return @@ -183,7 +183,7 @@ class SpookyNameRate(Cog):                  return          await ctx.send( -            f"But you don't have an entry... :eyes: Type `{Client.prefix}spookynamerate add your entry`" +            f"But you don't have an entry... :eyes: Type `{Bot.prefix}spookynamerate add your entry`"          )      @Cog.listener() @@ -223,7 +223,7 @@ class SpookyNameRate(Cog):                  "Okkey... Welcome to the **Spooky Name Rate Game**! It's a relatively simple game.\n"                  f"Everyday, a random name will be sent in <#{Channels.sir_lancebot_playground}> "                  "and you need to try and spookify it!\nRegister your name using " -                f"`{Client.prefix}spookynamerate add spookified name`" +                f"`{Bot.prefix}spookynamerate add spookified name`"              )              await self.data.set("first_time", False) @@ -348,7 +348,7 @@ class SpookyNameRate(Cog):              embed.add_field(                  name=(self.bot.get_user(data["author"]) or await self.bot.fetch_user(data["author"])).name, -                value=f"[{(data)['name']}](https://discord.com/channels/{Client.guild}/{channel.id}/{message_id})", +                value=f"[{(data)['name']}](https://discord.com/channels/{Bot.guild}/{channel.id}/{message_id})",              )          return embed @@ -368,9 +368,9 @@ class SpookyNameRate(Cog):          if SpookyNameRate.debug:              return True -        if not Client.month_override: +        if not Bot.month_override:              return datetime.utcnow().month == Month.OCTOBER -        return Client.month_override == Month.OCTOBER +        return Bot.month_override == Month.OCTOBER      def cog_check(self, ctx: Context) -> bool:          """A command to check whether the command is being called in October.""" diff --git a/bot/exts/holidays/pride/pride_leader.py b/bot/exts/holidays/pride/pride_leader.py index 120e9e16..94ba612e 100644 --- a/bot/exts/holidays/pride/pride_leader.py +++ b/bot/exts/holidays/pride/pride_leader.py @@ -82,7 +82,7 @@ class PrideLeader(commands.Cog):          )          embed.add_field(              name="For More Information", -            value=f"Do `{constants.Client.prefix}wiki {name}`" +            value=f"Do `{constants.Bot.prefix}wiki {name}`"                    f" in <#{constants.Channels.sir_lancebot_playground}>",              inline=False          ) diff --git a/bot/exts/utilities/cheatsheet.py b/bot/exts/utilities/cheatsheet.py index d7eb4917..48956de3 100644 --- a/bot/exts/utilities/cheatsheet.py +++ b/bot/exts/utilities/cheatsheet.py @@ -17,9 +17,9 @@ Unknown cheat sheet. Please try to reformulate your query.  **Examples**:  ```md -{constants.Client.prefix}cht read json -{constants.Client.prefix}cht hello world -{constants.Client.prefix}cht lambda +{constants.Bot.prefix}cht read json +{constants.Bot.prefix}cht hello world +{constants.Bot.prefix}cht lambda  ```  If the problem persists send a message in <#{Channels.dev_contrib}>  """ diff --git a/bot/exts/utilities/logging.py b/bot/exts/utilities/logging.py index 00febc2c..7f520522 100644 --- a/bot/exts/utilities/logging.py +++ b/bot/exts/utilities/logging.py @@ -23,7 +23,7 @@ class Logging(Cog):      async def check_channels(self) -> None:          """Verifies that all channel constants refer to channels which exist.""" -        if constants.Client.debug: +        if constants.Bot.debug:              log.info("Skipping Channels Check.")              return diff --git a/bot/exts/utilities/wtf_python.py b/bot/exts/utilities/wtf_python.py index 0c0375cb..f5db7a96 100644 --- a/bot/exts/utilities/wtf_python.py +++ b/bot/exts/utilities/wtf_python.py @@ -21,9 +21,9 @@ Unknown WTF Python Query. Please try to reformulate your query.  **Examples**:  ```md -{constants.Client.prefix}wtf wild imports -{constants.Client.prefix}wtf subclass -{constants.Client.prefix}wtf del +{constants.Bot.prefix}wtf wild imports +{constants.Bot.prefix}wtf subclass +{constants.Bot.prefix}wtf del  ```  If the problem persists send a message in <#{constants.Channels.dev_contrib}>  """ diff --git a/bot/utils/__init__.py b/bot/utils/__init__.py index 91682dbc..69439d91 100644 --- a/bot/utils/__init__.py +++ b/bot/utils/__init__.py @@ -9,7 +9,7 @@ from typing import Optional  import discord  from discord.ext.commands import BadArgument, Context -from bot.constants import Client, Month +from bot.constants import Bot, Month  from bot.utils.pagination import LinePaginator @@ -25,8 +25,8 @@ def resolve_current_month() -> Month:      If the env variable was set, current month always resolves to the configured value.      Otherwise, the current UTC month is given.      """ -    if Client.month_override is not None: -        return Month(Client.month_override) +    if Bot.month_override is not None: +        return Month(Bot.month_override)      else:          return Month(datetime.utcnow().month) diff --git a/bot/utils/checks.py b/bot/utils/checks.py index 857b6746..f21d2ddd 100644 --- a/bot/utils/checks.py +++ b/bot/utils/checks.py @@ -74,7 +74,7 @@ def in_whitelist_check(          return True      category = getattr(ctx_channel, "category", None) -    if category and category.name == constants.codejam_categories_name: +    if category and category.name == constants.CODEJAM_CATEGORY_NAME:          log.trace(f"{ctx.author} may use the `{ctx.command.name}` command as they are in a codejam team channel.")          return True | 
