- API Reference
- Frequently Asked Questions
- discord.py is dead! Will this library die too?
- Are you going to/will/consider fork(ing) discord.py?
- Will discord.py be able to work with this library?
- Where should we go with discord.py being gone?
- Why are you not supporting cooldowns?
- Will we not be able to create message commands?
- My question is not answered on here!
Looking into trying to get started with our library? Well, you’ve come to the right page then!
This quickstart guide is extremely rough and contains experimental code. Do not follow us strictly until v4.0 is released! Everything is subject to change in here due to the development of the API wrapper continuously being reflected.
discord-interactions is a Python library for the Discord Artificial Programming Interface. (API) A library in Python has to be installed through the pip file. Run this in your terminal/command line in order to install our library:
pip install -U discord-interactions
If you’re unable to run it through your terminal/command line, you need to make sure that it’s accessible as an Environment Path. Search more on Google for how to do this.
Bots can be a little confusing to create. That’s why we’ve decided to try and make the process as streamlined as humanly possible, in order for it to be friendlier to understand for our fellow bot developers. Please note that a Discord bot should not be your first project if you’re learning how to code. There are plenty of other projects to consider first before this, as a Discord bot is not exactly beginner-friendly.
This code block below shows a simple bot being created:
import interactions bot = interactions.Client(token="...") @bot.command( name="test", description="this is just a test command.", scope=1234567890 ) async def test(ctx): print("we're here so far.") # await ctx.send("Hello world!") bot.start()
There’s quite a lot of things that are going on here, so let’s break it down step-by-step:
import interactions– This is the import line. If this returns a
ModuleNotFoundError, please look at our Installing section here.
bot = interactions.Client(token="...")– This is the
botvariable that defines our bot. This basically instantiates the Client class, which requires a
tokenkeyword-argument to be passed. In order to get a token, please look at the image given below.
@bot.command()– This is something known as a decorator in Python. This decorator is in charge and responsible of making sure that the Discord API is told about the slash/sub command that you wish to create, and sends an HTTP request correspondingly. Any changes to the information contained in this decorator will be synchronously updated with the API automatically for you.
bot.start()– Finally, this is what tells our library to turn your bot from offline to online.
And it’s really as simple as that! If you would like to learn more about what our library offers, or see more examples of our code, please be sure to check out our coding examples page on our docs!