Skip to content

Commit

Permalink
5.11.0
Browse files Browse the repository at this point in the history
5.11.0
  • Loading branch information
LordOfPolls authored Nov 30, 2023
2 parents 0129d53 + 730b0f0 commit 1a7de56
Show file tree
Hide file tree
Showing 52 changed files with 424 additions and 50 deletions.
6 changes: 3 additions & 3 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
repos:
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.4.0
rev: v4.5.0
hooks:
- id: requirements-txt-fixer
name: Requirements
Expand Down Expand Up @@ -30,12 +30,12 @@ repos:
- id: check-merge-conflict
name: Merge Conflicts
- repo: https://github.com/astral-sh/ruff-pre-commit
rev: 'v0.0.282'
rev: 'v0.1.5'
hooks:
- id: ruff
args: [--fix, --exit-non-zero-on-fix]
- repo: https://github.com/psf/black
rev: 23.7.0
rev: 23.11.0
hooks:
- id: black
name: Black Formatting
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Hybrid Commands Index

- [Context](context)
Expand Down
5 changes: 5 additions & 0 deletions docs/src/API Reference/API Reference/ext/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Ext Index

These files contain useful features that help you develop a bot
Expand Down
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Prefixed Commands Index

- [Command](command)
Expand Down
5 changes: 5 additions & 0 deletions docs/src/API Reference/API Reference/models/Discord/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Discord Models Index

- [Activity](activity)
Expand Down
5 changes: 5 additions & 0 deletions docs/src/API Reference/API Reference/models/Internal/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Internal Models Index

- [Active Voice State](active_voice_state)
Expand Down
5 changes: 5 additions & 0 deletions docs/src/API Reference/API Reference/models/Misc/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Misc Models Index

- [Iterator](iterator)
5 changes: 5 additions & 0 deletions docs/src/API Reference/API Reference/models/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

# Models

Within these pages, you will find a list of all available models within interactions.py.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/01 Getting Started.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Introduction

Ready to get your Python on and create a Discord bot? This guide's got you covered with installation options and a basic bot code example.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/02 Creating Your Bot.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Creating Your Bot

To make a bot on Discord, you must first create an application on Discord. Thankfully, Discord has made this process very simple:
Expand Down
20 changes: 14 additions & 6 deletions docs/src/Guides/03 Creating Commands.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Slash Commands

So you want to make a slash command (or interaction, as they are officially called), but don't know how to get started?
Expand Down Expand Up @@ -263,7 +268,7 @@ In there, you have three seconds to return whatever choices you want to the user
from interactions import AutocompleteContext

@my_command_function.autocomplete("string_option")
async def autocomplete(self, ctx: AutocompleteContext):
async def autocomplete(ctx: AutocompleteContext):
string_option_input = ctx.input_text # can be empty
# you can use ctx.kwargs.get("name") to get the current state of other options - note they can be empty too

Expand Down Expand Up @@ -507,7 +512,7 @@ import traceback
from interactions.api.events import CommandError

@listen(CommandError, disable_default_listeners=True) # tell the dispatcher that this replaces the default listener
async def on_command_error(self, event: CommandError):
async def on_command_error(event: CommandError):
traceback.print_exception(event.error)
if not event.ctx.responded:
await event.ctx.send("Something went wrong.")
Expand All @@ -521,13 +526,16 @@ If your bot is complex enough, you might find yourself wanting to use custom mod

To do this, you'll want to use a string option, and define a converter. Information on how to use converters can be found [on the converter page](../08 Converters).

## Prefixed/Text Commands
## Hybrid Commands

!!! note
Prefixed commands, called by Discord as "text commands" and sometimes called "message commands" (not to be confused with Context Menu Message Commands), are commands that are triggered when a user sends a normal message with a designated "prefix" in front of them (ie `!my_command`).

To use prefixed commands, instead of typing `/my_command`, you will need to type instead `!my_command`, provided that the prefix you set is `!`.
interactions.py contains an extension for making these commands, which you can [read about here](/interactions.py/Guides/26 Prefixed Commands).

Hybrid commands are are slash commands that also get converted to an equivalent prefixed command under the hood. They are their own extension, and require [prefixed commands to be set up beforehand](/interactions.py/Guides/26 Prefixed Commands). After that, use the `setup` function in the `hybrid_commands` extension in your main bot file.

Your setup can (but doesn't necessarily have to) look like this:
Your setup should look similar to this:

```python
import interactions
Expand All @@ -549,7 +557,7 @@ async def my_command_function(ctx: HybridContext):
await ctx.send("Hello World")
```

Suggesting you are using the default mention settings for your bot, you should be able to run this command by `@BotPing my_command`.
Suggesting you are using the default mention settings for your bot, you should be able to run this command by typing out `@BotPing my_command` or using the slash command `/my_command`. Both will work largely equivalently.

As you can see, the only difference between hybrid commands and slash commands, from a developer perspective, is that they use `HybridContext`, which attempts
to seamlessly allow using the same context for slash and prefixed commands. You can always get the underlying context via `inner_context`, though.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/04 Context Menus.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Context Menus

Context menus are interactions under the hood. Defining them is very similar.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/05 Components.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Components

Components (Buttons, Select Menus and soon Text Input Fields) can be added to any message by passing them to the `components` argument in any `.send()` method.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/06 Modals.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Modals

Modals are basically popups which a user can use to send text information to your bot. As of the writing of this guide, you can use two components in a modal:
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/08 Converters.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Converters

If your bot is complex enough, you might find yourself wanting to use custom models in your commands. Converters are classes that allow you to do just that, and can be used in both slash and prefixed commands.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/10 Events.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Events

Events (in interactions.py) are pieces of information that are sent whenever something happens in Discord or in the library itself - this includes channel updates, message sending, the bot starting up, and more.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/20 Extensions.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Extensions

## Introduction
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/22 Live Patching.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Live Patching

interactions.py has a few built-in extensions that add some features, primarily for debugging. One of these extensions that you can enable separately is to add [`jurigged`](https://github.com/breuleux/jurigged) for live patching of code.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/23 Voice.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Voice Support

So you want to start playing some 🎵tunes🎶 in voice channels? Well let's get that going for you.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/24 Localisation.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Localising

So your bot has grown, and now you need to ~~localize~~ localise your bot. Well thank god we support localisation then, huh?
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/25 Error Tracking.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Error Tracking

So, you've finally got your bot running on a server somewhere. Chances are, you're not checking the console output 24/7, looking for exceptions.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/26 Prefixed Commands.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Creating Prefixed Commands

Prefixed commands, called by Discord as "text commands" and sometimes called "message commands" (not to be confused with Context Menu Message Commands), are commands that are triggered when a user sends a normal message with a designated "prefix" in front of them.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/30 Pagination.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Pagination

> Pagination, also known as paging, is the process of dividing a document into discrete pages, either electronic pages or printed pages.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/40 Tasks.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Tasks

Tasks are background processes that can be used to asynchronously run code with a specified trigger.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/80 Sharding.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Sharding

Oh damn, your bot is getting pretty big, huh? Well I guess its time we discuss sharding.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/90 Example.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Examples

## `main.py`
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/97 Migration From D.py.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Migrating from discord.py

1. interactions.py requires python 3.10 (as compared to dpy's 3.5), you may need to upgrade python.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/98 Migration from 4.X.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Migrating from 4.X

Version 5.X (and beyond) is a major rewrite of interactions.py compared to 4.X, though there have been major improvements to compensate for the change. 5.X was designed to be more stable and flexible, solving many of the bugs and UX issues 4.X had while also adding additional features you may like.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/99 2.x Migration_NAFF.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
boost: 3
---

# Migrating from NAFF

Oh hey! So you're migrating from NAFF to interactions.py? Well lets get you sorted.
Expand Down
5 changes: 5 additions & 0 deletions docs/src/Guides/index.md
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
---
search:
exclude: true
---

Let's be honest; reading API documentation is a bit of a pain.
These guides are meant to help you get started with the library and offer a point of reference.

Expand Down
2 changes: 2 additions & 0 deletions docs/src/index.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,8 @@ hide:
- navigation
- toc
- feedback
search:
exclude: true
---

We hope this documentation is helpful for you, but don't just ++ctrl+c++ and ++ctrl+v++.
Expand Down
18 changes: 10 additions & 8 deletions interactions/api/events/processors/scheduled_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -37,14 +37,16 @@ async def _on_raw_guild_scheduled_event_delete(self, event: "RawGatewayEvent") -

@Processor.define()
async def _on_raw_guild_scheduled_event_user_add(self, event: "RawGatewayEvent") -> None:
scheduled_event = self.cache.get_scheduled_event(event.data.get("guild_scheduled_event_id"))
user = self.cache.get_user(event.data.get("user_id"))

self.dispatch(events.GuildScheduledEventUserAdd(event.data.get("guild_id"), scheduled_event, user))
self.dispatch(
events.GuildScheduledEventUserAdd(
event.data["guild_id"], event.data["guild_scheduled_event_id"], event.data["user_id"]
)
)

@Processor.define()
async def _on_raw_guild_scheduled_event_user_remove(self, event: "RawGatewayEvent") -> None:
scheduled_event = self.cache.get_scheduled_event(event.data.get("guild_scheduled_event_id"))
user = self.cache.get_user(event.data.get("user_id"))

self.dispatch(events.GuildScheduledEventUserRemove(event.data.get("guild_id"), scheduled_event, user))
self.dispatch(
events.GuildScheduledEventUserRemove(
event.data["guild_id"], event.data["guild_scheduled_event_id"], event.data["user_id"]
)
)
2 changes: 1 addition & 1 deletion interactions/api/gateway/state.py
Original file line number Diff line number Diff line change
Expand Up @@ -128,7 +128,7 @@ async def _ws_connect(self) -> None:

except Exception as e:
self.client.dispatch(events.Disconnect())
self.wrapped_logger("".join(traceback.format_exception(type(e), e, e.__traceback__)))
self.wrapped_logger(logging.ERROR, "".join(traceback.format_exception(type(e), e, e.__traceback__)))

def wrapped_logger(self, level: int, message: str, **kwargs) -> None:
"""
Expand Down
4 changes: 2 additions & 2 deletions interactions/api/http/http_requests/scheduled_events.py
Original file line number Diff line number Diff line change
Expand Up @@ -58,11 +58,11 @@ async def get_scheduled_event(
return await self.request(
Route(
"GET",
"/guilds/{guild_id}/scheduled-events/{scheduled_event_id}",
"/guilds/{guild_id}/scheduled-events/{scheduled_event_id}?with_user_count={with_user_count}",
guild_id=guild_id,
scheduled_event_id=scheduled_event_id,
with_user_count=with_user_count,
),
params={"with_user_count": with_user_count},
)

async def create_scheduled_event(
Expand Down
Loading

0 comments on commit 1a7de56

Please sign in to comment.