Skip to content

Commit

Permalink
Merge commit 'd0a90693cd6a7d1f377e426270ed5937bb3bb0d8' into stable
Browse files Browse the repository at this point in the history
  • Loading branch information
silasary committed Aug 8, 2023
2 parents 5f7dc27 + d0a9069 commit 43a565c
Show file tree
Hide file tree
Showing 49 changed files with 1,096 additions and 457 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 43a565c

Please sign in to comment.