Skip to content

Migrating from NAFF

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.

1
2
3
4
5
6
7
8
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.

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:

1
2
3
4
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:

1
2
3
4
5
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.