CtrlK
BlogDocsLog inGet started
Tessl Logo

tessl/pypi-discord-py-interactions

A Feature-rich Discord Bot Framework for Python with comprehensive API coverage and modern interfaces

Pending
Quality

Pending

Does it follow best practices?

Impact

Pending

No eval scenarios have been run

SecuritybySnyk

Pending

The risk profile of this skill

Overview
Eval results
Files

Discord.py-Interactions

A modern Python library for building Discord bots with slash commands and interactions.

Package Information

Name: discord-py-interactions
Language: Python 3.10+
Installation: pip install discord-py-interactions
Repository: https://github.com/interactions-py/interactions.py

Core Imports

import interactions
from interactions import Client, AutoShardedClient, Intents
from interactions import slash_command, listen, Extension

Basic Usage

Simple Bot Setup

import interactions
from interactions import slash_command

bot = interactions.Client(token="YOUR_BOT_TOKEN", intents=interactions.Intents.DEFAULT)

@slash_command(name="hello", description="Say hello!")
async def hello(ctx):
    await ctx.send("Hello World!")

bot.start()

Bot with Events

import interactions
from interactions import listen, slash_command, events

bot = interactions.Client(token="YOUR_BOT_TOKEN")

@listen()
async def on_ready(event: events.Ready):
    print(f"Logged in as {event.user}")

@listen()
async def on_message_create(event: events.MessageCreate):
    print(f"Message: {event.message.content}")

@slash_command(name="ping")
async def ping(ctx):
    await ctx.send("Pong!")

bot.start()

Architecture

The library follows a modern, interaction-based architecture:

  1. Client-Centric Design: All functionality revolves around the Client class
  2. Decorator-Based Commands: Use decorators like @slash_command to define commands
  3. Event-Driven Architecture: Listen to Discord and internal events with @listen()
  4. Type-Safe: Extensive use of type hints and enums for better development experience
  5. Modular Extensions: Organize code using the Extension system

Capabilities

Client & Bot Management

Manage bot lifecycle, configuration, and connection handling.

from interactions import Client, AutoShardedClient, Intents, Status, Activity

Key APIs:

  • Client(token, intents) { .api }
  • AutoShardedClient(token) { .api }
  • client.start() { .api }
  • client.change_presence(status, activity) { .api }

Full Client Documentation

Discord Objects & Models

Comprehensive models for all Discord entities like guilds, users, channels, messages.

from interactions import Guild, User, Member, Channel, Message, Role, Permissions

Key APIs:

  • Guild.fetch_channels() { .api }
  • User.send(content) { .api }
  • Message.reply(content) { .api }
  • Member.add_role(role) { .api }

Full Discord Models Documentation

Commands & Interactions

Create slash commands, context menus, and handle all interaction types.

from interactions import slash_command, context_menu, SlashContext, ModalContext

Key APIs:

  • @slash_command(name, description) { .api }
  • @context_menu(name, context_type=CommandType.USER) { .api }
  • ctx.send(content, ephemeral=True) { .api }
  • ctx.defer() { .api }

Full Commands Documentation

Events & Listeners

Comprehensive event system covering Discord gateway events and internal bot events.

from interactions import listen, events

Key APIs:

  • @listen() { .api }
  • events.MessageCreate { .api }
  • events.Ready { .api }
  • events.GuildJoin { .api }

Full Events Documentation

User Interface Components

Interactive components like buttons, select menus, and modals.

from interactions import Button, Modal, ActionRow, StringSelectMenu

Key APIs:

  • Button(style=ButtonStyle.PRIMARY, label="Click Me") { .api }
  • Modal(title="Form", components=[...]) { .api }
  • @component_callback("button_id") { .api }
  • @modal_callback("modal_id") { .api }

Full Components Documentation

Extensions & Utilities

Extension system, converters, tasks, and utility functions.

from interactions import Extension, Task, Cooldown, check

Key APIs:

  • class MyExtension(Extension): ... { .api }
  • @Task.create(IntervalTrigger(seconds=60)) { .api }
  • @cooldown(Buckets.USER, 1, 30) { .api }
  • @check(lambda ctx: ctx.author.id == OWNER_ID) { .api }

Full Extensions Documentation

Workspace
tessl
Visibility
Public
Created
Last updated
Describes
pypipkg:pypi/discord-py-interactions@5.0.x
Publish Source
CLI
Badge
tessl/pypi-discord-py-interactions badge