Skip to content

Commit

Permalink
5.9.0 (#1512)
Browse files Browse the repository at this point in the history
* feat: add args, kwargs to task (#1478)

* modified:   interactions/models/internal/tasks/task.py

* reset to set_last_call_time

Signed-off-by: kennhh <[email protected]>

---------

Signed-off-by: kennhh <[email protected]>

* feat: add id attr to app perms update event

* revert: commit signoff err

* ci: show pre-commit diff on failure (#1484)

* feat: add alt methods for multi-arg params for prefixed cmds (#1471)

* feat: add alt methods for multi-arg params for prefixed cmds

* fix: use empty if the typehint is just tuple

* ci: correct from checks.

* fix: support ConsumeRest without typehint

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: cache channel data from interactions (#1479)

* fix: account for BaseChannel for channel mentions (#1480)

* feat: add default to delete/edit init interaction msg (#1481)

* docs: remove outdated cookiecutter template (#1483)

* docs: remove outdated cookiecutter template

* docs: add boilerplate mention

* feat: add id attr to app perms update event (#1485)

* feat: add sort order for forums (#1488)

* feat: add forum sort order

* feat: cache layout and sort order for forums

* feat: add rate limit per user where needed (#1489)

Signed-off-by: LordOfPolls <[email protected]>

* fix: use message channel for PrefixedContext (#1491)

* fix: bound app_permissions for HybridContext (#1492)

* feat: add start_time(s) for AutoShardedClient (#1482)

* feat: add start_time(s) for AutoShardedClient

* feat: make start_times a dict

* docs: make start_times docstring clearer

Co-authored-by: Sophia <[email protected]>
Signed-off-by: Astrea <[email protected]>

---------

Signed-off-by: Astrea <[email protected]>
Co-authored-by: Sophia <[email protected]>

* fix: correct listen typehint (#1495)

* chore: move mutable class ref/attrs to ClassVar typing (#1497)

* ci: weekly check. (#1460)

* ci: weekly check.

updates:
- https://github.com/charliermarsh/ruff-pre-commithttps://github.com/astral-sh/ruff-pre-commit
- [github.com/astral-sh/ruff-pre-commit: v0.0.272 → v0.0.278](astral-sh/ruff-pre-commit@v0.0.272...v0.0.278)
- [github.com/psf/black: 23.3.0 → 23.7.0](psf/black@23.3.0...23.7.0)

* ci: correct from checks.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: add ability to use different arg name than option name (#1493)

* feat: add ability to use different arg name than option name

* feat: raise better error if arg name doesnt exist

* fix: use ValueError instead of TypeError

TypeError seems to be suppressed

* fix: make sure exported auto_defer is deco, not module (#1496)

* fix/feat: adjust invite obj to respect event variants (#1500)

* fix/feat: adjust invite obj to respect event variants

* docs: update docs for event object

* revert: keep MISSING for backwards compatibility

* style: consistency

Co-authored-by: Sophia <[email protected]>
Signed-off-by: Astrea <[email protected]>

---------

Signed-off-by: Astrea <[email protected]>
Co-authored-by: Sophia <[email protected]>

* fix: address issues with tag usage for guild forums (#1499)

* fix: address issues with tags for guild forums

* fix: is this breaking? better be safe than sorry

* docs💥: revamp extension guide (#1494)

* docs💥: revamp extension guide

* docs: update extension example

* docs: oops, forgot a word

Co-authored-by: Max <[email protected]>
Signed-off-by: Astrea <[email protected]>

* docs: add section for loading all extensions in folder

* docs: turns out ipy can load multi exts in one file

* docs: lots of wording adjustments

---------

Signed-off-by: Astrea <[email protected]>
Co-authored-by: Max <[email protected]>
Co-authored-by: LordOfPolls <[email protected]>

* feat: add `guild` & `channel` properties to `ThreadMembersUpdate` (#1504)

* ci: weekly check. (#1503)

* ci: weekly check.

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.278 → v0.0.280](astral-sh/ruff-pre-commit@v0.0.278...v0.0.280)

* ci: correct from checks.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* fix(http): incorrect path for delete permission endpoint (#1506)

* fix delete_permissions api endpoint

fix API Endpoint in delete_channel_permission
adding "permissions/" in Endpoint

* ci: correct from checks.

---------

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* ci: weekly check. (#1511)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.280 → v0.0.281](astral-sh/ruff-pre-commit@v0.0.280...v0.0.281)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

* feat: Implement missing stuff for scheduled events (#1507)

* feat: Implement gateway support for scheduled events

* fix: add optional to user add/remove

* refactor: pre-commit'ed

* refactor: change attrs to props and add `attrs.field`

* refactor: set repr to True

* feat(client): add `get_scheduled_event` helper method

* refactor: use cache helpers in methods

* chore: replace typing

* docs: clarify intents in example (#1516)

* feat: infer modal/component callback names from coroutine (#1519)

* feat: infer callback decor from coroutine name

* docs: add new logic notation

* chore: add doc notation to component callback definition

* docs: clarify intents for extensions

* ci: weekly check. (#1521)

updates:
- [github.com/astral-sh/ruff-pre-commit: v0.0.281 → v0.0.282](astral-sh/ruff-pre-commit@v0.0.281...v0.0.282)

Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>

---------

Signed-off-by: kennhh <[email protected]>
Signed-off-by: LordOfPolls <[email protected]>
Signed-off-by: Astrea <[email protected]>
Co-authored-by: kennhh <[email protected]>
Co-authored-by: i0bs <[email protected]>
Co-authored-by: pre-commit-ci[bot] <66853113+pre-commit-ci[bot]@users.noreply.github.com>
Co-authored-by: LordOfPolls <[email protected]>
Co-authored-by: Max <[email protected]>
Co-authored-by: Damego <[email protected]>
Co-authored-by: Donbur4156 <[email protected]>
  • Loading branch information
8 people authored Aug 8, 2023
1 parent 5f7dc27 commit 738c0ad
Show file tree
Hide file tree
Showing 48 changed files with 1,095 additions and 456 deletions.
2 changes: 1 addition & 1 deletion .github/workflows/precommit.yml
Original file line number Diff line number Diff line change
Expand Up @@ -17,4 +17,4 @@ jobs:
pip install pre-commit
- name: Run Pre-commit
run: |
pre-commit run --all-files
pre-commit run --all-files --show-diff-on-failure
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -29,13 +29,13 @@ repos:
name: TOML Structure
- id: check-merge-conflict
name: Merge Conflicts
- repo: https://github.com/charliermarsh/ruff-pre-commit
rev: 'v0.0.272'
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.282'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.3.0
rev: 23.7.0
hooks:
- id: black
name: Black Formatting
Expand Down
125 changes: 48 additions & 77 deletions docs/src/Guides/01 Getting Started.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,102 +9,73 @@ Ready to get your Python on and create a Discord bot? This guide's got you cover
- [x] [A bot account](02 Creating Your Bot.md)
- [ ] An aversion to puns

## Installation Methods
## Installing and Setting up a Bot

There are two different ways to install this library and create your bot.
### Virtual Environments

=== "Using a Template"
We strongly recommend that you make use of Virtual Environments when working on any project.
This means that each project will have its own libraries of any version and does not affect anything else on your system.
Don't worry, this isn't setting up a full-fledged virtual machine, just small python environment.

We created a [cookiecutter template](https://github.com/Discord-Snake-Pit/Bot-Template) which you can use to set up your own bot faster.
With the template, your code will already have a well-defined structure which will make development easier for you.

We recommend newer devs to make use of this template.

### Template Feature
- Basic, ready to go bot
- Implementation of best practises
- General extensibility
- Example command, context menu, component, and event
- Logging to both console and file
- Pip and poetry config
- Pre-commit config
- Dockerfile and pre-made docker-compose

### Template Installation
1. Install cookiecutter - `pip install cookiecutter`
2. Set up the template - `cookiecutter https://github.com/Discord-Snake-Pit/Bot-Template`

And that's it!

More information can be found [here](https://github.com/Discord-Snake-Pit/Bot-Template).


=== "Manual Installation"

### Virtual-Environments

We strongly recommend that you make use of Virtual Environments when working on any project.
This means that each project will have its own libraries of any version and does not affect anything else on your system.
Don't worry, this isn't setting up a full-fledged virtual machine, just small python environment.

=== ":material-linux: Linux"
```shell
cd "[your bots directory]"
python3 -m venv venv
source venv/bin/activate
```
=== ":material-linux: Linux"
```shell
cd "[your bots directory]"
python3 -m venv venv
source venv/bin/activate
```

=== ":material-microsoft-windows: Windows"
```shell
cd "[your bots directory]"
py -3 -m venv venv
venv/Scripts/activate
```
=== ":material-microsoft-windows: Windows"
```shell
cd "[your bots directory]"
py -3 -m venv venv
venv/Scripts/activate
```

It's that simple, now you're using a virtual environment. If you want to leave the environment just type `deactivate`.
If you want to learn more about the virtual environments, check out [this page](https://docs.python.org/3/tutorial/venv.html)
It's that simple, now you're using a virtual environment. If you want to leave the environment just type `deactivate`.
If you want to learn more about the virtual environments, check out [this page](https://docs.python.org/3/tutorial/venv.html)

### Pip install
### Pip install

Now let's get the library installed.
Now let's get the library installed.

=== ":material-linux: Linux"
```shell
python3 -m pip install discord-py-interactions --upgrade
```
=== ":material-linux: Linux"
```shell
python3 -m pip install discord-py-interactions --upgrade
```

=== ":material-microsoft-windows: Windows"
```shell
py -3 -m pip install discord-py-interactions --upgrade
```
=== ":material-microsoft-windows: Windows"
```shell
py -3 -m pip install discord-py-interactions --upgrade
```

### Basic bot
### Basic bot

Now let's get a basic bot going, for your code, you'll want something like this:
!!! note
This is a very basic bot. For a more detailed example/template bot that demonstrates many parts of interactions.py, see [the boilerplate repository.](https://github.com/interactions-py/boilerplate)

```python
from interactions import Client, Intents, listen
Now let's get a basic bot going, for your code, you'll want something like this:

bot = Client(intents=Intents.DEFAULT)
# intents are what events we want to receive from discord, `DEFAULT` is usually fine
```python
from interactions import Client, Intents, listen

@listen() # this decorator tells snek that it needs to listen for the corresponding event, and run this coroutine
async def on_ready():
# This event is called when the bot is ready to respond to commands
print("Ready")
print(f"This bot is owned by {bot.owner}")
bot = Client(intents=Intents.DEFAULT)
# intents are what events we want to receive from discord, `DEFAULT` is usually fine

@listen() # this decorator tells snek that it needs to listen for the corresponding event, and run this coroutine
async def on_ready():
# This event is called when the bot is ready to respond to commands
print("Ready")
print(f"This bot is owned by {bot.owner}")

@listen()
async def on_message_create(event):
# This event is called when a message is sent in a channel the bot can see
print(f"message received: {event.message.content}")

@listen()
async def on_message_create(event):
# This event is called when a message is sent in a channel the bot can see
print(f"message received: {event.message.content}")

bot.start("Put your token here")
```

---
bot.start("Put your token here")
```

Congratulations! You now have a basic understanding of this library.
If you have any questions check out our other guides, or join the
Expand Down
Loading

0 comments on commit 738c0ad

Please sign in to comment.