Skip to content
This repository has been archived by the owner on Mar 13, 2023. It is now read-only.

Commit

Permalink
NAFF 2.0.0
Browse files Browse the repository at this point in the history
NAFF 2.0.0
  • Loading branch information
LordOfPolls authored Nov 20, 2022
2 parents c04efbf + 76417c8 commit 55b66b1
Show file tree
Hide file tree
Showing 126 changed files with 4,205 additions and 1,904 deletions.
17 changes: 13 additions & 4 deletions .github/pull_request_template.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,18 +5,27 @@
- [ ] Breaking code change
- [ ] Documentation change/addition
- [ ] Tests change
- [ ] CI change
- [ ] Other: [Replace with a description]

## Description
<!-- Clearly and concisely describe what this PR is for, and why you feel it should be merged. -->


## Changes
<!-- - A bullet pointed list outlining the changes you have made -->
<!-- - A bullet-pointed list outlining the changes you have made -->


## Checklist
## Test Scenario(s)
<!-- If you changed any code, please provide us with clear instructions on how you verified your changes work. This includes test code. If you don't have a test scenario, please provide an explanation as to why this change does need to be tested. -->


<!-- These are actions you **must** have taken, if you haven't, your PR will be rejected -->
## Checklist
<!-- Please check which actions you have taken -->
- [ ] I've formatted my code with [Black](https://black.readthedocs.io/en/stable/)
- [ ] I've added docstrings to everything I've touched
- [ ] I've ensured my code works on `Python 3.10.x`
- [ ] I've tested my code
- [ ] I've ensured my code works on `Python 3.11.x`
- [ ] I've tested my changes
- [ ] I've added tests for my code - if applicable
- [ ] I've updated the documentation - if applicable
10 changes: 5 additions & 5 deletions .github/workflows/codeql-analysis.yml
Original file line number Diff line number Diff line change
Expand Up @@ -39,15 +39,15 @@ jobs:

steps:
- name: Checkout repository
uses: actions/checkout@v2
uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'

# Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL
uses: github/codeql-action/init@v1
uses: github/codeql-action/init@v2
with:
languages: ${{ matrix.language }}
# If you wish to specify custom queries, you can do so here or in a config file.
Expand All @@ -58,7 +58,7 @@ jobs:
# Autobuild attempts to build any compiled languages (C/C++, C#, or Java).
# If this step fails, then you should remove it and run the build manually (see below)
- name: Autobuild
uses: github/codeql-action/autobuild@v1
uses: github/codeql-action/autobuild@v2

# ℹ️ Command-line programs to run using the OS shell.
# 📚 https://git.io/JvXDl
Expand All @@ -72,4 +72,4 @@ jobs:
# make release

- name: Perform CodeQL Analysis
uses: github/codeql-action/analyze@v1
uses: github/codeql-action/analyze@v2
6 changes: 3 additions & 3 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,13 +8,13 @@ jobs:
runs-on: ubuntu-latest
if: github.event.repository.fork == false
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
with:
fetch-depth: 0
- uses: actions/setup-python@v2
- uses: actions/setup-python@v4
with:
python-version: "3.10"
- uses: actions/cache@v2
- uses: actions/cache@v3
with:
key: ${{ github.ref }}
path: .cache
Expand Down
2 changes: 1 addition & 1 deletion .github/workflows/ok-to-test.yml
Original file line number Diff line number Diff line change
Expand Up @@ -25,7 +25,7 @@ jobs:
private_key: ${{ secrets.PRIVATE_KEY }}

- name: Slash Command Dispatch
uses: peter-evans/slash-command-dispatch@v1
uses: peter-evans/slash-command-dispatch@v3
env:
TOKEN: ${{ steps.generate_token.outputs.token }}
with:
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,9 +5,9 @@ jobs:
name: runner / Pre-commit actions
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python 3.10
uses: actions/setup-python@v2.3.1
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Setup annotations
Expand Down
4 changes: 2 additions & 2 deletions .github/workflows/publish.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,9 +7,9 @@ jobs:
deploy:
runs-on: ubuntu-latest
steps:
- uses: actions/checkout@v2
- uses: actions/checkout@v3
- name: Set up Python
uses: actions/setup-python@v2
uses: actions/setup-python@v4
with:
python-version: '3.10'
- name: Install dependencies
Expand Down
22 changes: 16 additions & 6 deletions .github/workflows/pytest-pr.yml
Original file line number Diff line number Diff line change
Expand Up @@ -15,10 +15,20 @@ jobs:
- .[speedup]
- .[voice]
- .[all]
python-version:
- "3.10"
- "3.11"
include:
- extras: .[all]
python-version: "3.10"
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
- extras: .[all]
python-version: "3.11"
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}

steps:
- name: Create check run
uses: actions/github-script@v5
uses: actions/github-script@v6
id: create-check-run
env:
number: ${{ github.event.client_payload.pull_request.number }}
Expand All @@ -42,13 +52,13 @@ jobs:
return result.id;
- name: Fork based /ok-to-test checkout
uses: actions/checkout@v2
uses: actions/checkout@v3
with:
ref: 'refs/pull/${{ github.event.client_payload.pull_request.number }}/merge'
- name: Set up Python 3.10
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}
- name: Install ffmpeg & opus
run: sudo apt-get install ffmpeg libopus-dev
- name: Install pytest
Expand All @@ -67,14 +77,14 @@ jobs:
chmod +x codecov
./codecov
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/TestResults.xml'
check_name: 'Pytest Results'

- name: Update check run
uses: actions/github-script@v5
uses: actions/github-script@v6
id: update-check-run
if: ${{ always() }}
env:
Expand Down
21 changes: 17 additions & 4 deletions .github/workflows/pytest-push.yml
Original file line number Diff line number Diff line change
Expand Up @@ -13,22 +13,35 @@ jobs:
- .[voice]
- .[all]
- .[docs]
python-version:
- "3.10"
- "3.11"
include:
- extras: .[all]
python-version: "3.10"
RUN_TESTBOT: true
- extras: .[all]
python-version: "3.11"
RUN_TESTBOT: true

steps:
- uses: actions/checkout@v2
- name: Set up Python 3.10
- uses: actions/checkout@v3
- name: Set up Python ${{ matrix.python-version }}
uses: actions/[email protected]
with:
python-version: '3.10'
python-version: ${{ matrix.python-version }}
cache: 'pip'
- name: Install ffmpeg & opus
run: sudo apt-get update && sudo apt-get install ffmpeg libopus-dev
- name: Install pytest
run: |
pip install wheel
pip install -e ${{ matrix.extras }}
pip install .[tests]
- name: Run Tests
env:
BOT_TOKEN: ${{ secrets.BOT_TOKEN }}
RUN_TESTBOT: ${{ matrix.RUN_TESTBOT }}
run: |
pytest
coverage xml -i
Expand All @@ -38,7 +51,7 @@ jobs:
chmod +x codecov
./codecov
- name: Publish Test Report
uses: mikepenz/action-junit-report@v2
uses: mikepenz/action-junit-report@v3
if: always() # always run even if the previous step fails
with:
report_paths: '**/TestResults.xml'
Expand Down
3 changes: 3 additions & 0 deletions docs/src/API Reference/ext/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@ These files contain useful features that help you develop a bot
- [Debug Extension](debug_ext)
- An extension preloaded with a load of debugging utilities to help you find and fix bugs

- [Jurigged](jurigged)
- An extension to enable live code patching for faster development

- [Paginators](paginators)
- An automatic message paginator to help you get a lot of information across

Expand Down
1 change: 1 addition & 0 deletions docs/src/API Reference/ext/jurigged.md
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
::: naff.ext.jurigged
22 changes: 12 additions & 10 deletions docs/src/Guides/05 Components.md
Original file line number Diff line number Diff line change
Expand Up @@ -99,20 +99,18 @@ await channel.send("Look a Button!", components=components)

Sometimes there might be more than a handful options which users need to decide between. That's when a `Select` should probably be used.

Selects are very similar to Buttons. The main difference is that they need options, which you supply by passing a list of `SelectOption`.
Selects are very similar to Buttons. The main difference is that you get a list of options to choose from.

If you want to use string options, then you use `StringSelect`. Simply pass a list of strings to `options` and you are good to go. You can also explicitly pass `SelectOptions` to control the value attribute.

You can also define how many options users can choose by setting `min_values` and `max_values`.

```python
components = Select(
from naff import StringSelectMenu, SelectOption

components = StringSelectMenu(
options=[
SelectOption(
label="Pizza",
value="Pizza"
),
SelectOption(
label="Egg Sandwich",
value="Egg Sandwich"
),
"Pizza", "Pasta", "Burger", "Salad"
],
placeholder="What is your favourite food?",
min_values=1,
Expand All @@ -124,6 +122,10 @@ await channel.send("Look a Select!", components=components)
??? note
You can only have upto 25 options in a Select

Alternatively, you can use `RoleSelectMenu`, `UserSelectMenu` and `ChannelSelectMenu` to select roles, users and channels respectively. These select menus are very similar to `StringSelectMenu`, but they don't allow you to pass a list of options; it's all done behind the scenes.

```python

For more information, please visit the API reference [here](/API Reference/models/Discord/components/#naff.models.discord.components.Select).

## Responding
Expand Down
19 changes: 19 additions & 0 deletions docs/src/Guides/22 Live Patching.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,19 @@
# Live Patching

NAFF has a few built-in extensions that add some features, primarily for debugging. One of these extensions that you can enable separately is to add [`jurigged`](https://github.com/breuleux/jurigged) for live patching of code.

## How to enable

```py
bot.load_extension("naff.ext.jurigged")
```

That's it! The extension will handle all of the leg work, and all you'll notice is that you have more messages in your logs (depending on the log level).

## What is jurigged?

`jurigged` is a library written to allow code hot reloading in Python. It allows you to edit code and have it automagically be updated in your program the next time it is run. The code under the hood is extremely complicated, but the interface to use it is relatively simple.

## How is this useful?

NAFF takes advantage of jurigged to reload any and all commands that were edited whenever a change is made, allowing you to have more uptime with while still adding/improving features of your bot.
File renamed without changes.
File renamed without changes.
File renamed without changes.
Loading

0 comments on commit 55b66b1

Please sign in to comment.