|
75 | 75 | from ..poll import Poll |
76 | 76 | from ..state import ConnectionState |
77 | 77 | from ..types.components import Modal as ModalPayload |
| 78 | + from ..types.guild import PartialGuild as PartialGuildPayload |
78 | 79 | from ..types.interactions import ( |
79 | 80 | ApplicationCommandOptionChoice as ApplicationCommandOptionChoicePayload, |
80 | 81 | Interaction as InteractionPayload, |
@@ -204,7 +205,7 @@ def __init__(self, *, data: InteractionPayload, state: ConnectionState) -> None: |
204 | 205 | self.version: int = data["version"] |
205 | 206 | self.application_id: int = int(data["application_id"]) |
206 | 207 | self.guild_id: Optional[int] = utils._get_as_snowflake(data, "guild_id") |
207 | | - self._guild: Optional[Mapping[str, Any]] = data.get("guild") |
| 208 | + self._guild: Optional[PartialGuildPayload] = data.get("guild") |
208 | 209 |
|
209 | 210 | self.locale: Locale = try_enum(Locale, data["locale"]) |
210 | 211 | guild_locale = data.get("guild_locale") |
@@ -275,12 +276,20 @@ def guild(self) -> Optional[Guild]: |
275 | 276 | guild = self._state._get_guild(self.guild_id) |
276 | 277 | if guild: |
277 | 278 | return guild |
| 279 | + if self._guild is None: |
| 280 | + return None |
278 | 281 |
|
279 | 282 | # create a guild mash |
280 | 283 | # honestly we should cache this for the duration of the interaction |
281 | 284 | # but not if we fetch it from the cache, just the result of this creation |
282 | 285 | guild = Guild(data=self._guild, state=self._state) |
283 | | - guild._add_role(Role(state=self._state, guild=guild, data={"id": 1, "name": "@everyone"})) |
| 286 | + guild._add_role( |
| 287 | + Role( |
| 288 | + state=self._state, |
| 289 | + guild=guild, |
| 290 | + data={"id": 1, "name": "@everyone"}, # type: ignore |
| 291 | + ) |
| 292 | + ) |
284 | 293 | return guild |
285 | 294 |
|
286 | 295 | @utils.cached_slot_property("_cs_me") |
|
0 commit comments