Skip to content

Commit 1a7de56

Browse files
authored
5.11.0
5.11.0
2 parents 0129d53 + 730b0f0 commit 1a7de56

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

52 files changed

+424
-50
lines changed

.pre-commit-config.yaml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
repos:
22
- repo: https://github.com/pre-commit/pre-commit-hooks
3-
rev: v4.4.0
3+
rev: v4.5.0
44
hooks:
55
- id: requirements-txt-fixer
66
name: Requirements
@@ -30,12 +30,12 @@ repos:
3030
- id: check-merge-conflict
3131
name: Merge Conflicts
3232
- repo: https://github.com/astral-sh/ruff-pre-commit
33-
rev: 'v0.0.282'
33+
rev: 'v0.1.5'
3434
hooks:
3535
- id: ruff
3636
args: [--fix, --exit-non-zero-on-fix]
3737
- repo: https://github.com/psf/black
38-
rev: 23.7.0
38+
rev: 23.11.0
3939
hooks:
4040
- id: black
4141
name: Black Formatting

docs/src/API Reference/API Reference/ext/hybrid_commands/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Hybrid Commands Index
27

38
- [Context](context)

docs/src/API Reference/API Reference/ext/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Ext Index
27

38
These files contain useful features that help you develop a bot

docs/src/API Reference/API Reference/ext/prefixed_commands/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Prefixed Commands Index
27

38
- [Command](command)

docs/src/API Reference/API Reference/models/Discord/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Discord Models Index
27

38
- [Activity](activity)

docs/src/API Reference/API Reference/models/Internal/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Internal Models Index
27

38
- [Active Voice State](active_voice_state)
Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Misc Models Index
27

38
- [Iterator](iterator)

docs/src/API Reference/API Reference/models/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
# Models
27

38
Within these pages, you will find a list of all available models within interactions.py.

docs/src/Guides/01 Getting Started.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Introduction
27

38
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.

docs/src/Guides/02 Creating Your Bot.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Creating Your Bot
27

38
To make a bot on Discord, you must first create an application on Discord. Thankfully, Discord has made this process very simple:

docs/src/Guides/03 Creating Commands.md

Lines changed: 14 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Slash Commands
27

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

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

@@ -507,7 +512,7 @@ import traceback
507512
from interactions.api.events import CommandError
508513

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

522527
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).
523528

524-
## Prefixed/Text Commands
529+
## Hybrid Commands
530+
531+
!!! note
532+
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`).
525533

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

528536
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.
529537

530-
Your setup can (but doesn't necessarily have to) look like this:
538+
Your setup should look similar to this:
531539

532540
```python
533541
import interactions
@@ -549,7 +557,7 @@ async def my_command_function(ctx: HybridContext):
549557
await ctx.send("Hello World")
550558
```
551559

552-
Suggesting you are using the default mention settings for your bot, you should be able to run this command by `@BotPing my_command`.
560+
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.
553561

554562
As you can see, the only difference between hybrid commands and slash commands, from a developer perspective, is that they use `HybridContext`, which attempts
555563
to seamlessly allow using the same context for slash and prefixed commands. You can always get the underlying context via `inner_context`, though.

docs/src/Guides/04 Context Menus.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Context Menus
27

38
Context menus are interactions under the hood. Defining them is very similar.

docs/src/Guides/05 Components.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Components
27

38
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.

docs/src/Guides/06 Modals.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Modals
27

38
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:

docs/src/Guides/08 Converters.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Converters
27

38
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.

docs/src/Guides/10 Events.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Events
27

38
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.

docs/src/Guides/20 Extensions.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Extensions
27

38
## Introduction

docs/src/Guides/22 Live Patching.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Live Patching
27

38
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.

docs/src/Guides/23 Voice.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Voice Support
27

38
So you want to start playing some 🎵tunes🎶 in voice channels? Well let's get that going for you.

docs/src/Guides/24 Localisation.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Localising
27

38
So your bot has grown, and now you need to ~~localize~~ localise your bot. Well thank god we support localisation then, huh?

docs/src/Guides/25 Error Tracking.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Error Tracking
27

38
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.

docs/src/Guides/26 Prefixed Commands.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Creating Prefixed Commands
27

38
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.

docs/src/Guides/30 Pagination.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Pagination
27

38
> Pagination, also known as paging, is the process of dividing a document into discrete pages, either electronic pages or printed pages.

docs/src/Guides/40 Tasks.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Tasks
27

38
Tasks are background processes that can be used to asynchronously run code with a specified trigger.

docs/src/Guides/80 Sharding.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Sharding
27

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

docs/src/Guides/90 Example.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Examples
27

38
## `main.py`

docs/src/Guides/97 Migration From D.py.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Migrating from discord.py
27

38
1. interactions.py requires python 3.10 (as compared to dpy's 3.5), you may need to upgrade python.

docs/src/Guides/98 Migration from 4.X.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Migrating from 4.X
27

38
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.

docs/src/Guides/99 2.x Migration_NAFF.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
boost: 3
4+
---
5+
16
# Migrating from NAFF
27

38
Oh hey! So you're migrating from NAFF to interactions.py? Well lets get you sorted.

docs/src/Guides/index.md

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
---
2+
search:
3+
exclude: true
4+
---
5+
16
Let's be honest; reading API documentation is a bit of a pain.
27
These guides are meant to help you get started with the library and offer a point of reference.
38

docs/src/index.md

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,8 @@ hide:
33
- navigation
44
- toc
55
- feedback
6+
search:
7+
exclude: true
68
---
79

810
We hope this documentation is helpful for you, but don't just ++ctrl+c++ and ++ctrl+v++.

interactions/api/events/processors/scheduled_events.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -37,14 +37,16 @@ async def _on_raw_guild_scheduled_event_delete(self, event: "RawGatewayEvent") -
3737

3838
@Processor.define()
3939
async def _on_raw_guild_scheduled_event_user_add(self, event: "RawGatewayEvent") -> None:
40-
scheduled_event = self.cache.get_scheduled_event(event.data.get("guild_scheduled_event_id"))
41-
user = self.cache.get_user(event.data.get("user_id"))
42-
43-
self.dispatch(events.GuildScheduledEventUserAdd(event.data.get("guild_id"), scheduled_event, user))
40+
self.dispatch(
41+
events.GuildScheduledEventUserAdd(
42+
event.data["guild_id"], event.data["guild_scheduled_event_id"], event.data["user_id"]
43+
)
44+
)
4445

4546
@Processor.define()
4647
async def _on_raw_guild_scheduled_event_user_remove(self, event: "RawGatewayEvent") -> None:
47-
scheduled_event = self.cache.get_scheduled_event(event.data.get("guild_scheduled_event_id"))
48-
user = self.cache.get_user(event.data.get("user_id"))
49-
50-
self.dispatch(events.GuildScheduledEventUserRemove(event.data.get("guild_id"), scheduled_event, user))
48+
self.dispatch(
49+
events.GuildScheduledEventUserRemove(
50+
event.data["guild_id"], event.data["guild_scheduled_event_id"], event.data["user_id"]
51+
)
52+
)

interactions/api/gateway/state.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -128,7 +128,7 @@ async def _ws_connect(self) -> None:
128128

129129
except Exception as e:
130130
self.client.dispatch(events.Disconnect())
131-
self.wrapped_logger("".join(traceback.format_exception(type(e), e, e.__traceback__)))
131+
self.wrapped_logger(logging.ERROR, "".join(traceback.format_exception(type(e), e, e.__traceback__)))
132132

133133
def wrapped_logger(self, level: int, message: str, **kwargs) -> None:
134134
"""

interactions/api/http/http_requests/scheduled_events.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -58,11 +58,11 @@ async def get_scheduled_event(
5858
return await self.request(
5959
Route(
6060
"GET",
61-
"/guilds/{guild_id}/scheduled-events/{scheduled_event_id}",
61+
"/guilds/{guild_id}/scheduled-events/{scheduled_event_id}?with_user_count={with_user_count}",
6262
guild_id=guild_id,
6363
scheduled_event_id=scheduled_event_id,
64+
with_user_count=with_user_count,
6465
),
65-
params={"with_user_count": with_user_count},
6666
)
6767

6868
async def create_scheduled_event(

0 commit comments

Comments
 (0)