From afa46c4abfc73c8791742ed2ece886776823e8ab Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Sat, 23 Jul 2022 14:47:06 +0200 Subject: Add Sample Project With Boilerplate Adds a bare-bones discord.py bot using features from bot-core, to be used for quickly prototyping and testing out bot-core features. Signed-off-by: Hassan Abouelela --- dev/README.rst | 45 +++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 45 insertions(+) create mode 100644 dev/README.rst (limited to 'dev/README.rst') diff --git a/dev/README.rst b/dev/README.rst new file mode 100644 index 00000000..b1535962 --- /dev/null +++ b/dev/README.rst @@ -0,0 +1,45 @@ +Local Development & Testing +=========================== + +To test your features locally, there are a few possible approaches: + +1. Install your local copy of botcore into a pre-existing project such as bot +2. Use the provided template from the :repo-file:`dev/bot ` folder + +See below for more info on both approaches. + +What's going to be common between them is you'll need to write code to test your feature. +This might mean adding new commands, modifying existing ones, changing utilities, etc. +The steps below should provide most of the groundwork you need, but the exact requirements will +vary by the feature you're working on. + + +Option 1 +-------- +1. Navigate to the project you want to install bot-core in, such as bot or sir-lancebot +2. Run ``pip install /path/to/botcore`` in the project's environment + + - The path provided to install should be the root directory of this project on your maching. + That is, the folder which contains the ``pyproject.toml`` file. + - Make sure to install in the correct environment. Most Python Discord projects use + poetry, so you can run ``poetry run pip install /path/to/botcore``. + +3. You can now use features from your local bot-core changes. + To load new changes, run the install command again. + + +Option 2 +-------- +1. Copy the :repo-file:`bot template folder ` to the root of your project. + This copy is going to be git-ignored, so you're free to modify it however you like. +2. Run the project + + - Locally: You can run it on your system using ``python -m bot`` + - Docker: You can run on docker using ``docker compose up -d bot``. + +3. You can now test your changes. You do not need to do anything to reinstall the + library if you modify your code. + +.. tip:: + The docker-compose included contains services from our other applications + to help you test out certain features. Use them as needed. -- cgit v1.2.3 From 0e0b8933e4654bcfd80708c54a63c272bb5cbbd1 Mon Sep 17 00:00:00 2001 From: Hassan Abouelela Date: Sat, 23 Jul 2022 17:00:16 +0200 Subject: Document Sample Project Environment Variables Co-authored-by: Chris Lovering Signed-off-by: Hassan Abouelela --- dev/README.rst | 14 +++++++++++--- 1 file changed, 11 insertions(+), 3 deletions(-) (limited to 'dev/README.rst') diff --git a/dev/README.rst b/dev/README.rst index b1535962..afff6255 100644 --- a/dev/README.rst +++ b/dev/README.rst @@ -19,7 +19,7 @@ Option 1 1. Navigate to the project you want to install bot-core in, such as bot or sir-lancebot 2. Run ``pip install /path/to/botcore`` in the project's environment - - The path provided to install should be the root directory of this project on your maching. + - The path provided to install should be the root directory of this project on your machine. That is, the folder which contains the ``pyproject.toml`` file. - Make sure to install in the correct environment. Most Python Discord projects use poetry, so you can run ``poetry run pip install /path/to/botcore``. @@ -30,14 +30,22 @@ Option 1 Option 2 -------- -1. Copy the :repo-file:`bot template folder ` to the root of your project. +1. Copy the :repo-file:`bot template folder ` to the root of the bot-core project. This copy is going to be git-ignored, so you're free to modify it however you like. 2. Run the project - Locally: You can run it on your system using ``python -m bot`` - Docker: You can run on docker using ``docker compose up -d bot``. -3. You can now test your changes. You do not need to do anything to reinstall the +3. Configure the environment variables used by the program. + You can set them in an ``.env`` file in the project root directory. The variables are: + + - ``TOKEN`` (required): Discord bot token, with all intents enabled + - ``GUILD_ID`` (required): The guild the bot should monitor + - ``PREFIX``: The prefix to use for invoking bot commands. Defaults to mentions and ``!`` + - ``ALLOWED_ROLES``: A comma seperated list of role IDs which the bot is allowed to mention + +4. You can now test your changes. You do not need to do anything to reinstall the library if you modify your code. .. tip:: -- cgit v1.2.3 From ce894c0706d64756cdcd046f5729958425a803fc Mon Sep 17 00:00:00 2001 From: Chris Lovering Date: Sat, 10 Sep 2022 20:45:54 +0100 Subject: Use BOT_TOKEN in example project This is so that we use the same env var as metricity, remove the need for duplicate env vars. --- dev/README.rst | 2 +- dev/bot/__main__.py | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) (limited to 'dev/README.rst') diff --git a/dev/README.rst b/dev/README.rst index afff6255..ae4f3adc 100644 --- a/dev/README.rst +++ b/dev/README.rst @@ -40,7 +40,7 @@ Option 2 3. Configure the environment variables used by the program. You can set them in an ``.env`` file in the project root directory. The variables are: - - ``TOKEN`` (required): Discord bot token, with all intents enabled + - ``BOT_TOKEN`` (required): Discord bot token, with all intents enabled - ``GUILD_ID`` (required): The guild the bot should monitor - ``PREFIX``: The prefix to use for invoking bot commands. Defaults to mentions and ``!`` - ``ALLOWED_ROLES``: A comma seperated list of role IDs which the bot is allowed to mention diff --git a/dev/bot/__main__.py b/dev/bot/__main__.py index 00ebdefc..42d212c2 100644 --- a/dev/bot/__main__.py +++ b/dev/bot/__main__.py @@ -29,6 +29,6 @@ async def main() -> None: """Run the bot.""" bot.http_session = aiohttp.ClientSession() async with bot: - await bot.start(os.getenv("TOKEN")) + await bot.start(os.getenv("BOT_TOKEN")) asyncio.run(main()) -- cgit v1.2.3