Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
51 changes: 51 additions & 0 deletions docs/src/Guides/99 2.x Migration_NAFF.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,51 @@
Oh hey! So you're migrating from NAFF to interactions.py? Well lets get you sorted.

First and foremost, you'll need to install the new library. You can do this by running `pip install interactions.py` in your terminal.
Then, the first thing you'll need to do is change your imports. You'll need to change `from naff import _` to `from interactions import _`. To be honest, assuming your code is relatively simple, you should be able to use find and replace to do this.

## Prefixed Commands
I.py moves prefixed commands to an extension, rather than being a part of the client. So to use them you'll need to load them.
```python
from interactions import Client, Intents
from interactions.ext import prefixed_commands

# guild messages are included in the default intents ipy uses
# if you wish for the prefix to be anything but mentioning the bot,
# guild message content will also be required
client = Client(..., intents=Intents.GUILD_MESSAGES | ...)
prefixed_commands.setup(client)
```
From here it's more or less the same as before. You can find a guide on how to use prefixed commands [here](/Guides/26 Prefixed Commands.md).

## Hybrid Commands
For now, hybrid commands are not supported, but they will be in the future.

## Enums
To get us on the same page. Enums are a way of defining a set of constants. For a Discord example, ButtonStyles.
In v5, enums are no longer plural. So `ButtonStyles` is now `ButtonStyle`. This applies to all enums in the library.

## StringSelectMenu
`StringSelectMenu` now takes it's options as positional arguments, rather than a list. This means that you can no longer do `StringSelectMenu(options=[...])`, instead the quickest way to do it is `StringSelectMenu(*[...])`.
Alternatively, I recommend this syntax:
```python
StringSelectMenu(
"Thing 1", "Thing 2", "Thing 3",
placeholder="Pick a thing"
)
```
This is much more readable, and removes useless boilerplate.

## Modals
Much like `StringSelectMenu`, Modals now take their children as positional arguments, rather than a list. This means that you can no longer do `Modal(components=[...])`, instead the quickest way to do it is `Modal(*[...])`.
Again, the same recommendation applies here:
```python
Modal(
ShortText(label="Short Input Text", custom_id="short_text"),
ParagraphText(label="Long Input Text", custom_id="long_text"),
title="My Modal",
)
```

## Kwargs Vs. Args
V5 prefers kwargs over args. This means for the majority of methods and objects, they expect their arguments to be passed as kwargs, rather than args. This is to make the library more readable, and to make it easier to add new arguments in the future.
The **only** exceptions to this are list-like objects, like `ActionRow`, `StringSelectMenu`, `Modal`, where the children are passed as args in order to keep the syntax clean.
8 changes: 7 additions & 1 deletion docs/src/Guides/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,7 @@ These guides are meant to help you get started with the library and offer a poin

Oh damn, your bot is getting pretty big, huh? Well I guess its time we discuss sharding.

- [__:material-frequently-asked-questions: Migration from discord.py__](99 Migration From D.py.md)
- [__:material-frequently-asked-questions: Migration from discord.py__](100 Migration From D.py.md)

---

Expand All @@ -112,5 +112,11 @@ These guides are meant to help you get started with the library and offer a poin

How do I migrate from i.py v4.4 to v5?

- [__:material-package-up: 2.x Migration Guide__](99 2.x Migration_NAFF.md)

---

How do I migrate from NAFF to i.py v5?


</div>