Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
215 commits
Select commit Hold shift + click to select a range
86b3570
Format examples and add another example
EmpathyYT Oct 3, 2021
143319b
Update Info.py
EmpathyYT Oct 3, 2021
6568287
Update examples/Info.py
EmpathyYT Oct 3, 2021
b09868e
Update examples/Info.py
EmpathyYT Oct 3, 2021
0795f44
simpler example that doubles as a slash command
EmpathyYT Oct 3, 2021
37b964a
Update Info.py
EmpathyYT Oct 3, 2021
d1ba226
Update examples/Info.py
EmpathyYT Oct 4, 2021
5a19180
fixed all issues
EmpathyYT Oct 4, 2021
6bf4471
Update Info.py
EmpathyYT Oct 4, 2021
2fbffee
Update Info.py
EmpathyYT Oct 4, 2021
90c4098
Update Info.py
EmpathyYT Oct 4, 2021
472cde8
Delete Info.py
EmpathyYT Oct 27, 2021
e6c846e
Create Info.py
EmpathyYT Oct 27, 2021
85a0455
Document application commands (#308)
Dorukyum Oct 29, 2021
275163f
Fix documentation structure for application commands
BobDotCom Oct 31, 2021
a738ac6
add type hints
Luc1412 Nov 7, 2021
087f243
type hinted the typehints
Luc1412 Nov 8, 2021
65adfe7
add return type typing on discord.ui.*
ultrabear Nov 10, 2021
67570ce
type hinting pain
Luc1412 Nov 10, 2021
b548116
Merge branch 'typehint' into master
Luc1412 Nov 10, 2021
3618c00
Merge pull request #1 from Luc1412/master
Luc1412 Nov 10, 2021
20c7876
Merge pull request #430 from Pycord-Development/master
Lulalaby Nov 11, 2021
0bb8080
Update discord/bot.py
Luc1412 Nov 11, 2021
5319d90
remove code from #424 idk how it even came into this fork lol
Luc1412 Nov 11, 2021
00c0964
type hint non type hinted types
Luc1412 Nov 11, 2021
fa105be
type hinted the context
Luc1412 Nov 11, 2021
656792b
improved imports
Luc1412 Nov 11, 2021
48e66db
improved permissions.py
Luc1412 Nov 11, 2021
b606887
Document application command types
Dorukyum Nov 13, 2021
2edb2e4
Merge pull request #427 from ultrabear/master
Lulalaby Nov 17, 2021
662f2af
Remove ids and grammar changes.
capslock321 Nov 17, 2021
8616080
more changes
capslock321 Nov 17, 2021
9e1e3df
Update examples/views/button_roles.py
Lulalaby Nov 17, 2021
313d9f2
Add files via upload
krishsharma0413 Nov 22, 2021
936254f
updated with better documentation
krishsharma0413 Nov 22, 2021
a8b0bc7
improved button_cog.py examples
krishsharma0413 Nov 22, 2021
b516192
simplified examples
krishsharma0413 Nov 23, 2021
c78313d
Update button_cog.py
krishsharma0413 Nov 23, 2021
de7bced
Apply suggestions from code review
Lulalaby Nov 26, 2021
337a9a0
Merge branch 'master' into patch-1
Lulalaby Nov 27, 2021
73e4cbe
Merge branch 'document-app-commands' of https://github.com/Pycord-Dev…
Dorukyum Nov 27, 2021
4e2d1a6
Document options
Dorukyum Nov 27, 2021
8d35ac0
Fix documentation syntax
Dorukyum Nov 27, 2021
4ec23bd
examples
krishsharma0413 Nov 29, 2021
9863fcb
spelling correction
krishsharma0413 Nov 29, 2021
5f1b7a6
Fix documentation bug
BobDotCom Nov 29, 2021
37b7297
Fix documentation bug and move migrating file
BobDotCom Nov 29, 2021
8476acb
Merge branch 'migrating' of https://github.com/bobdotcom/pycord into …
BobDotCom Nov 29, 2021
d12155c
First commit for 2.0 migration guide
BobDotCom Nov 29, 2021
53322d4
Update examples/interactionsBot/bot.py
krishsharma0413 Nov 30, 2021
faa979c
Initial Refresh
VincentRPS Nov 30, 2021
fa2b7d8
Fixing Some Stuff
VincentRPS Nov 30, 2021
40c568e
Update examples/views/button_roles.py
Lulalaby Nov 30, 2021
ebbbbe8
Remove d.py logo
VincentRPS Nov 30, 2021
85500c2
Changed Styling
VincentRPS Nov 30, 2021
bf2a19a
Having stuff on Migrating: 2.0
VincentRPS Nov 30, 2021
471471c
Fix
VincentRPS Nov 30, 2021
e6a2d83
Fixing
VincentRPS Nov 30, 2021
0d4eabd
Adding Some Stuff To Changelog
VincentRPS Nov 30, 2021
1c27d18
Make some fixes
VincentRPS Nov 30, 2021
5f96343
Adding Docs workflow
VincentRPS Nov 30, 2021
640ac2a
Merge branch 'Pycord-Development:master' into refresh/docs
VincentRPS Nov 30, 2021
1b731ec
Replacing Images With Updated Ones
VincentRPS Nov 30, 2021
fa7f257
Trying to see how blurple would look
VincentRPS Nov 30, 2021
ef5cb5d
Fixing Some Doc Types And Lints Docs
VincentRPS Nov 30, 2021
f6e0e26
Added Notice So I Don't forget
VincentRPS Nov 30, 2021
b799740
Apply suggestions from code review
Lulalaby Nov 30, 2021
2877110
Update docs/whats_new.rst
VincentRPS Nov 30, 2021
66fc64a
Fix
VincentRPS Nov 30, 2021
1ec86e5
Merge remote-tracking branch 'bob/migrating' into pr/523
Lulalaby Nov 30, 2021
c858b76
Revert ambiguous merge commit
BobDotCom Nov 30, 2021
cc1a21e
Fix documentation errors part 1
BobDotCom Nov 30, 2021
15cf6ea
Fix documentation errors part 2
BobDotCom Nov 30, 2021
c7d623e
Fix documentation errors part 3
BobDotCom Nov 30, 2021
06ed779
Re-adding Old Versions
VincentRPS Dec 1, 2021
0cd6eb5
Change To Grey From Blurple
VincentRPS Dec 1, 2021
10f4877
Fix Typos
VincentRPS Dec 2, 2021
d6bee97
Fixing More Typos And Making More TODO:'s
VincentRPS Dec 2, 2021
eb5e0b2
Fixes
VincentRPS Dec 2, 2021
0eadb58
Making Title Cards Smaller
VincentRPS Dec 2, 2021
6f63da8
Making Title Cards Smaller
VincentRPS Dec 2, 2021
8871d90
Making Title Cards Smaller
VincentRPS Dec 2, 2021
ec16ec8
Remove Old Migrating From Page
VincentRPS Dec 2, 2021
d16e8c3
Fix
VincentRPS Dec 2, 2021
11fb2a3
Update docs/intents.rst
Lulalaby Dec 2, 2021
d3d1242
Update docs/migrating.rst
Lulalaby Dec 2, 2021
e5ba1ef
Fixing Examples
VincentRPS Dec 3, 2021
0896e71
Fixes
VincentRPS Dec 3, 2021
d168f82
Fixes
VincentRPS Dec 3, 2021
aa480ff
Advance Documentation Here
VincentRPS Dec 3, 2021
a454bba
Fixes
VincentRPS Dec 3, 2021
0e6d574
Fix
VincentRPS Dec 3, 2021
8f4393c
Merge pull request #1 from RPSMain/fix
krishsharma0413 Dec 3, 2021
975c5af
Update Info.py
EmpathyYT Dec 4, 2021
b813799
Should be the final translation thing?
VincentRPS Dec 5, 2021
9fa456d
Start Working On The Guide
VincentRPS Dec 7, 2021
1d5d6ad
Fix
VincentRPS Dec 7, 2021
6c7e7a6
Fixes Again
VincentRPS Dec 7, 2021
75f17d0
Mega Guide Commit
VincentRPS Dec 7, 2021
8014cc4
Finish Autcomplete & Add Images
VincentRPS Dec 7, 2021
f2a91fc
Fix
VincentRPS Dec 7, 2021
f9336f8
Fix Images
VincentRPS Dec 7, 2021
38a9dba
Expand Webhooks Guide
VincentRPS Dec 7, 2021
2cfe238
Fixed?
VincentRPS Dec 7, 2021
bcec84c
Expand Docs and Change file positions
VincentRPS Dec 7, 2021
05bf68f
Moving Guide like Files To Guide
VincentRPS Dec 7, 2021
9059169
Fix Links
VincentRPS Dec 7, 2021
a345362
Quick Fix
VincentRPS Dec 7, 2021
cb3ff96
Move Location Of TODO
VincentRPS Dec 8, 2021
29d87a8
Remove Guide For ext.menus
VincentRPS Dec 8, 2021
5510660
Mega Commit
VincentRPS Dec 8, 2021
1b0dfe2
Fix Index Names
VincentRPS Dec 8, 2021
8739935
Mega Commit and expands button & select Views
VincentRPS Dec 8, 2021
ad75915
Finish Permissions Guide
VincentRPS Dec 8, 2021
157ef20
Fix Capitalization
VincentRPS Dec 8, 2021
2d5c77b
Remove Sub Command Guide
VincentRPS Dec 8, 2021
8f42662
Fix Spelling Errors
VincentRPS Dec 8, 2021
1483e5f
Adding MyST Parser
VincentRPS Dec 8, 2021
46162c0
Remove TODO
VincentRPS Dec 8, 2021
84f4560
Merge branch 'refresh/docs' of https://github.com/pycord/pycord into …
VincentRPS Dec 8, 2021
8c4bf5a
Fix Up Version Guarantees
VincentRPS Dec 8, 2021
fa2ae8f
Title Card Chananigans
VincentRPS Dec 8, 2021
9afad5e
More Fixes To Title Cards
VincentRPS Dec 8, 2021
871abb4
Fix Capitalization
VincentRPS Dec 8, 2021
5ba221e
Fix Capitalization
VincentRPS Dec 8, 2021
f5ca179
Fix Capitalization
VincentRPS Dec 8, 2021
c5d41c3
Fix Capitalization
VincentRPS Dec 8, 2021
67657a5
Fix Capitalization
VincentRPS Dec 8, 2021
2c722b4
Fix Capitalization
VincentRPS Dec 8, 2021
6cec05c
Fix Capitalization
VincentRPS Dec 8, 2021
1e9f825
Fix Capitalization
VincentRPS Dec 8, 2021
2a1b760
Fix Capitalization
VincentRPS Dec 8, 2021
788130f
Fix Capitalization
VincentRPS Dec 8, 2021
64f6a35
Fix NOTE Capitalization
VincentRPS Dec 8, 2021
55883c6
Fix Capitalization
VincentRPS Dec 8, 2021
3743bb1
Fix Capitalization
VincentRPS Dec 8, 2021
1bcdb18
Remove Image Load
VincentRPS Dec 8, 2021
a988c9f
Typo
VincentRPS Dec 8, 2021
c89997e
Adding Tips To Guide
VincentRPS Dec 8, 2021
07881bf
Document CMD Prompt Stuff
VincentRPS Dec 8, 2021
9f2cc5e
Looks Better
VincentRPS Dec 8, 2021
1029b9f
Fix
VincentRPS Dec 10, 2021
ae86970
Merge pull request #470 from capslock321/patch-1
Lulalaby Dec 12, 2021
eeb9a48
Apply suggestions from code review
Lulalaby Dec 13, 2021
c99dbcf
Update examples/app_commands/Info.py
Lulalaby Dec 13, 2021
1ba9ff4
make this easier to see
VincentRPS Dec 13, 2021
9ac90f6
wut
VincentRPS Dec 13, 2021
a9559c4
Update and rename Info.py to info.py
EmpathyYT Dec 14, 2021
0395fba
Document Slash Groups
VincentRPS Dec 15, 2021
65b4276
Fix
VincentRPS Dec 15, 2021
6e58d07
Grammar
VincentRPS Dec 15, 2021
71268a1
Merge pull request #249 from EmpathyYT/master
Lulalaby Dec 16, 2021
f5181f9
Merge pull request #428 from Luc1412/typehint
Lulalaby Dec 17, 2021
fde7a8d
Merge branch 'trunk/docs' into core/typing
Lulalaby Dec 17, 2021
c782b85
Make less of a guide
VincentRPS Dec 18, 2021
3463f1e
Some Stuff
VincentRPS Dec 18, 2021
2fe20d0
Merge pull request #484 from ResetXD/master
Lulalaby Dec 19, 2021
3e5ff39
update Inviting Your Bot instructions
QiCuiHub Dec 21, 2021
73a8a8f
Merge pull request #568 from pycord/document-app-commands
Lulalaby Dec 22, 2021
8cb1d0c
Merge branch 'master' into document-app-commands
Lulalaby Dec 22, 2021
14e842c
Fix docs
Lulalaby Dec 22, 2021
7a046a1
Merge pull request #609 from QiCuiHub/master
Lulalaby Dec 22, 2021
3e628b3
fix scope
Lulalaby Dec 22, 2021
237cfd4
Added note that activity bots won't be verified
Lulalaby Dec 22, 2021
c4bd0cb
Fix spelling
Lulalaby Dec 22, 2021
8efafe7
Add locale and guild locale
Lulalaby Dec 22, 2021
0446ef2
change urls
Lulalaby Dec 22, 2021
c2cbade
Move cogs section to the bottom
Dorukyum Dec 22, 2021
3ebb6d8
Explain group parameters better
Dorukyum Dec 22, 2021
45beb87
Explain subcommands better
Dorukyum Dec 22, 2021
26c693c
Minor changes
Dorukyum Dec 23, 2021
b488442
Document slash command groups using classes
Dorukyum Dec 23, 2021
8c42595
Document custom converters for options
Dorukyum Dec 23, 2021
621cd54
Merge branch 'master' into document-app-commands
Lulalaby Dec 23, 2021
4dfe451
Merge branch 'master' of https://github.com/Pycord-Development/pycord…
VincentRPS Dec 24, 2021
faf8fd3
Merge branch 'Pycord-Development:master' into refresh/docs
VincentRPS Dec 27, 2021
ccf21a9
Expand The Guide Way More
VincentRPS Dec 27, 2021
7a668ea
Expand the guide more
VincentRPS Dec 27, 2021
d3939b7
Create German Translations
VincentRPS Dec 27, 2021
93ad905
Fix Translation Error
VincentRPS Dec 27, 2021
227129e
quick fix
VincentRPS Dec 27, 2021
0283d49
undo translations
VincentRPS Dec 31, 2021
477bfb6
some progress
VincentRPS Jan 12, 2022
825a8eb
fix typos
VincentRPS Jan 12, 2022
2a8b68e
Merge branch 'master' into refresh/docs
VincentRPS Jan 12, 2022
6898b51
separate branch from bob's fork
VincentRPS Jan 13, 2022
50de3cf
fix
VincentRPS Jan 13, 2022
c6794d4
i forgor
VincentRPS Jan 13, 2022
fb794c5
Merge branch 'trunk/docs' into refresh/docs
VincentRPS Jan 13, 2022
8a0ef98
fix :skull:
VincentRPS Jan 13, 2022
c64624a
Merge pull request #770 from pycord/refresh/docs
Lulalaby Jan 13, 2022
b2af7e5
Merge branch 'master' into trunk/docs
Lulalaby Jan 13, 2022
409d33b
Apply suggestions from code review
Lulalaby Jan 14, 2022
34afde8
Update discord/client.py
Lulalaby Jan 14, 2022
c694357
Merge branch 'document-app-commands' into trunk/docs
Lulalaby Jan 22, 2022
2bff39b
Merge branch 'master' into trunk/docs
Lulalaby Jan 22, 2022
7e3dde5
Merge branch 'master' into core/typing
Middledot Jan 23, 2022
17d3272
Merge branch 'trunk/docs' into core/typing
Middledot Jan 23, 2022
6414d79
refactor: undo guide
VincentRPS Jan 23, 2022
96540a4
Update core.py
Lulalaby Jan 23, 2022
ae9ab1f
Rename slash_cog.py to basicSlash_cog.py
Lulalaby Jan 23, 2022
13bb2b9
Update README.rst
Lulalaby Jan 23, 2022
fc8ead9
fix: merge conflicts
VincentRPS Jan 23, 2022
0539435
Merge branch 'master' into trunk/docs
Dorukyum Jan 24, 2022
96076bf
Merge branch 'trunk/docs' into core/typing
Middledot Jan 24, 2022
bf0d3d8
Merge branch 'master' into core/typing
Middledot Jan 24, 2022
c1959f9
Fix wrong typing imports
Middledot Jan 24, 2022
ed6f271
Add typing_extensions to requirements
Middledot Jan 24, 2022
a0938e3
Add a requirement to docs workflows
Middledot Jan 24, 2022
a125783
Higher python version of docs workflow
Middledot Jan 24, 2022
95f9394
Docs workflow typo
Middledot Jan 24, 2022
9df0685
Commit to re-run jobs
Middledot Jan 27, 2022
f3241f8
Merge branch 'master' into core/typing
Lulalaby Jan 27, 2022
edb0c51
Possible fix for docs typehint execution
Middledot Jan 27, 2022
5e20801
Merge branch 'core/typing' of https://github.com/Pycord-Development/p…
Middledot Jan 27, 2022
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions .github/workflows/docs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ jobs:
runs-on: ubuntu-latest
strategy:
matrix:
python-version: [ 3.8 ]
python-version: [ '3.10' ]
steps:
- uses: actions/checkout@v2
- name: Set up Python ${{ matrix.python-version }}
Expand All @@ -17,7 +17,7 @@ jobs:
- name: Install dependencies
run: |
python -m pip install -U pip
pip install -U sphinx sphinxcontrib-trio aiohttp sphinxcontrib-websupport myst-parser
pip install -U sphinx sphinxcontrib-trio aiohttp sphinxcontrib-websupport myst-parser typing-extensions
- name: Compile to html
run: |
cd docs
Expand Down
4 changes: 2 additions & 2 deletions discord/asset.py
Original file line number Diff line number Diff line change
Expand Up @@ -268,11 +268,11 @@ def __str__(self) -> str:
def __len__(self) -> int:
return len(self._url)

def __repr__(self):
def __repr__(self) -> str:
shorten = self._url.replace(self.BASE, '')
return f'<Asset url={shorten!r}>'

def __eq__(self, other):
def __eq__(self, other) -> bool:
return isinstance(other, Asset) and self._url == other._url

def __hash__(self):
Expand Down
1 change: 1 addition & 0 deletions discord/bot.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,6 +40,7 @@
Type,
TypeVar,
Union,
Type,
)

from .client import Client
Expand Down
16 changes: 16 additions & 0 deletions discord/commands/_types.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,16 @@
from typing import Callable, TYPE_CHECKING, Union, Coroutine, Any, TypeVar

if TYPE_CHECKING:
from .. import Cog, ApplicationContext

T = TypeVar('T')

Coro = Coroutine[Any, Any, T]
MaybeCoro = Union[T, Coro[T]]
CoroFunc = Callable[..., Coro[Any]]

Check = Union[Callable[["Cog", "ApplicationContext[Any]"], MaybeCoro[bool]],
Callable[["ApplicationContext[Any]"], MaybeCoro[bool]]]
Hook = Union[Callable[["Cog", "ApplicationContext[Any]"], Coro[Any]], Callable[["ApplicationContext[Any]"], Coro[Any]]]
Error = Union[Callable[["Cog", "ApplicationContext[Any]", "CommandError"], Coro[Any]],
Callable[["ApplicationContext[Any]", "CommandError"], Coro[Any]]]
133 changes: 82 additions & 51 deletions discord/commands/context.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,21 +24,26 @@
"""
from __future__ import annotations

from typing import TYPE_CHECKING, Optional, TypeVar, Union
from typing import TYPE_CHECKING, Optional, Union, TypeVar, Generic, Callable, List, Any, Dict

import discord.abc
import discord.utils

if TYPE_CHECKING:
from typing_extensions import ParamSpec

import discord
from discord import Bot
from discord.state import ConnectionState

from .core import ApplicationCommand, Option
from . import ApplicationCommand, Option
from ..cog import Cog
from ..webhook import WebhookMessage
from typing import Callable
from ..embeds import Embed
from ..file import File
from ..guild import Guild
from ..interactions import Interaction, InteractionChannel, InteractionResponse, InteractionMessage
from ..member import Member
from ..mentions import AllowedMentions
from ..message import Message
from ..state import ConnectionState
from ..user import User
from ..ui import View
from ..voice_client import VoiceProtocol
from ..webhook import Webhook, WebhookMessage
from typing_extensions import ParamSpec

from ..guild import Guild
from ..interactions import Interaction, InteractionResponse
Expand All @@ -58,7 +63,18 @@
__all__ = ("ApplicationContext", "AutocompleteContext")


class ApplicationContext(discord.abc.Messageable):
MISSING: Any = discord.utils.MISSING

T = TypeVar("T")
BotT = TypeVar("BotT", bound="Union[discord.Bot, discord.AutoShardedBot]")
CogT = TypeVar("CogT", bound="Cog")

if TYPE_CHECKING:
P = ParamSpec('P')
else:
P = TypeVar('P')

class ApplicationContext(discord.abc.Messageable, Generic[BotT]):
"""Represents a Discord application command interaction context.

This class is not created manually and is instead passed to application
Expand All @@ -76,9 +92,9 @@ class ApplicationContext(discord.abc.Messageable):
The command that this context belongs to.
"""

def __init__(self, bot: Bot, interaction: Interaction):
self.bot = bot
self.interaction = interaction
def __init__(self, bot: BotT, interaction: Interaction) -> None:
self.bot: BotT = bot
self.interaction: Interaction = interaction

# below attributes will be set after initialization
self.command: ApplicationCommand = None # type: ignore
Expand All @@ -88,7 +104,7 @@ def __init__(self, bot: Bot, interaction: Interaction):

self._state: ConnectionState = self.interaction._state

async def _get_channel(self) -> discord.abc.Messageable:
async def _get_channel(self) -> Optional[InteractionChannel]:
return self.channel

async def invoke(self, command: ApplicationCommand[CogT, P, T], /, *args: P.args, **kwargs: P.kwargs) -> T:
Expand Down Expand Up @@ -118,7 +134,7 @@ async def invoke(self, command: ApplicationCommand[CogT, P, T], /, *args: P.args
return await command(self, *args, **kwargs)

@cached_property
def channel(self):
def channel(self) -> Optional[InteractionChannel]:
return self.interaction.channel

@cached_property
Expand All @@ -133,14 +149,6 @@ def guild(self) -> Optional[Guild]:
def guild_id(self) -> Optional[int]:
return self.interaction.guild_id

@cached_property
def locale(self) -> Optional[str]:
return self.interaction.locale

@cached_property
def guild_locale(self) -> Optional[str]:
return self.interaction.guild_locale

@cached_property
def me(self) -> Union[Member, User]:
return self.guild.me if self.guild is not None else self.bot.user
Expand Down Expand Up @@ -168,6 +176,14 @@ def voice_client(self):
def response(self) -> InteractionResponse:
return self.interaction.response

@property
def cog(self) -> Optional[Cog]:
"""Optional[:class:`.Cog`]: Returns the cog associated with this context's command. ``None`` if it does not exist."""
if self.command is None:
return None

return self.command.cog

@property
def respond(self) -> Callable[..., Union[Interaction, WebhookMessage]]:
"""Callable[..., Union[:class:`~.Interaction`, :class:`~.Webhook`]]: Sends either a response
Expand Down Expand Up @@ -195,33 +211,42 @@ def send_followup(self):
f"Interaction was not yet issued a response. Try using {type(self).__name__}.respond() first."
)

@property
def defer(self):
return self.interaction.response.defer
@discord.utils.copy_doc(InteractionResponse.defer)
async def defer(self, *, ephemeral: bool = False) -> None:
return await self.interaction.response.defer(ephemeral=ephemeral)

@property
def followup(self):
def followup(self) -> Webhook:
return self.interaction.followup

async def delete(self):
async def delete(self) -> None:
"""Calls :attr:`~discord.commands.ApplicationContext.respond`.
If the response is done, then calls :attr:`~discord.commands.ApplicationContext.respond` first."""
if not self.response.is_done():
await self.defer()

return await self.interaction.delete_original_message()

@property
def edit(self):
return self.interaction.edit_original_message

@property
def cog(self) -> Optional[Cog]:
"""Optional[:class:`.Cog`]: Returns the cog associated with this context's command. ``None`` if it does not exist."""
if self.command is None:
return None

return self.command.cog
async def edit(
self,
*,
content: Optional[str] = MISSING,
embeds: List[Embed] = MISSING,
embed: Optional[Embed] = MISSING,
file: File = MISSING,
files: List[File] = MISSING,
view: Optional[View] = MISSING,
allowed_mentions: Optional[AllowedMentions] = None,
) -> InteractionMessage:
return await self.interaction.edit_original_message(
content=content,
embeds=embeds,
embed=embed,
file=file,
files=files,
view=view,
allowed_mentions=allowed_mentions,
)


class AutocompleteContext:
Expand All @@ -248,18 +273,24 @@ class AutocompleteContext:
"""

__slots__ = ("bot", "interaction", "command", "focused", "value", "options")

def __init__(self, bot: Bot, interaction: Interaction) -> None:
self.bot = bot
self.interaction = interaction

self.command: ApplicationCommand = None # type: ignore
self.focused: Option = None # type: ignore
self.value: str = None # type: ignore
self.options: dict = None # type: ignore

def __init__(
self,
interaction: Interaction,
*,
command: ApplicationCommand,
focused: Option,
value: str,
options: Dict[str, Any],
) -> None:
self.interaction: Interaction = interaction
self.command: ApplicationCommand = command
self.focused: Option = focused
self.value: str = value
self.options: Dict[str, Any] = options

@property
def cog(self) -> Optional[Cog]:
def cog(self) -> Optional[CogT]:
"""Optional[:class:`.Cog`]: Returns the cog associated with this context's command. ``None`` if it does not exist."""
if self.command is None:
return None
Expand Down
Loading