Passed
Pull Request — main (#292)
by
unknown
01:45
created

pincer.objects.guild.guild.Guild.delete_sticker()   A

Complexity

Conditions 1

Size

Total Lines 11
Code Lines 2

Duplication

Lines 0
Ratio 0 %

Importance

Changes 0
Metric Value
eloc 2
dl 0
loc 11
rs 10
c 0
b 0
f 0
cc 1
nop 2
1
# Copyright Pincer 2021-Present
0 ignored issues
show
introduced by
Missing module docstring
Loading history...
coding-style introduced by
Too many lines in module (1633/1000)
Loading history...
2
# Full MIT License can be found in `LICENSE` at the project root.
3
4
from __future__ import annotations
5
6
from collections import AsyncIterator
0 ignored issues
show
Bug introduced by
The name AsyncIterator does not seem to exist in module collections.
Loading history...
7
from dataclasses import dataclass, field
8
from enum import IntEnum
9
from typing import AsyncGenerator, overload, TYPE_CHECKING
10
11
from .invite import Invite
12
from .channel import Channel
13
from ..message.emoji import Emoji
14
from ..message.file import File
15
from ...exceptions import UnavailableGuildError
16
from ...utils.api_object import APIObject
17
from ...utils.conversion import construct_client_dict, remove_none
18
from ...utils.types import MISSING
19
20
21
if TYPE_CHECKING:
22
    from typing import Any, Dict, List, Optional, Union
23
24
    from .audit_log import AuditLog
25
    from .ban import Ban
26
    from .member import GuildMember
27
    from .features import GuildFeature
28
    from .role import Role
29
    from .stage import StageInstance
30
    from .template import GuildTemplate
31
    from .welcome_screen import WelcomeScreen, WelcomeScreenChannel
32
    from .widget import GuildWidget
33
    from .webhook import Webhook
34
    from ..user.user import User
35
    from ..user.integration import Integration
36
    from ..voice.region import VoiceRegion
37
    from ..events.presence import PresenceUpdateEvent
38
    from ..message.emoji import Emoji
0 ignored issues
show
Unused Code introduced by
The import Emoji was already done on line 13. You should be able to
remove this line.
Loading history...
39
    from ..message.sticker import Sticker, StickerPack
40
    from ..user.voice_state import VoiceState
41
    from ...client import Client
42
    from ...utils.timestamp import Timestamp
43
    from ...utils.types import APINullable, JSONSerializable
44
    from ...utils.snowflake import Snowflake
45
46
47
class PremiumTier(IntEnum):
48
    """Represents the boost tier of a guild.
49
    Attributes
50
    ----------
51
    NONE:
52
        Guild has not unlocked any Server Boost perks.
53
    TIER_1:
54
        Guild has unlocked Server Boost level 1 perks.
55
    TIER_2:
56
        Guild has unlocked Server Boost level 2 perks.
57
    TIER_3:
58
        Guild has unlocked Server Boost level 3 perks.
59
    """
60
61
    NONE = 0
62
    TIER_1 = 1
63
    TIER_2 = 2
64
    TIER_3 = 3
65
66
67
class GuildNSFWLevel(IntEnum):
68
    """Represents the NSFW level of a guild.
69
    Attributes
70
    ----------
71
    DEFAULT:
72
        Default NSFW level.
73
    EXPLICIT:
74
        Explicit NSFW level.
75
    SAFE:
76
        SAFE NSFW level.
77
    AGE_RESTRICTED:
78
        Age restricted NSFW level.
79
    """
80
81
    DEFAULT = 0
82
    EXPLICIT = 1
83
    SAFE = 2
84
    AGE_RESTRICTED = 3
85
86
87
class ExplicitContentFilterLevel(IntEnum):
88
    """Represents the filter content level of a guild.
89
    Attributes
90
    ----------
91
    DISABLED:
92
        Media content will not be scanned.
93
    MEMBERS_WITHOUT_ROLES:
94
        Media content sent by members without roles will be scanned.
95
    ALL_MEMBERS:
96
        Media content sent by all members will be scanned.
97
    """
98
99
    DISABLED = 0
100
    MEMBERS_WITHOUT_ROLES = 1
101
    ALL_MEMBERS = 2
102
103
104
class MFALevel(IntEnum):
105
    """Represents the multi factor authentication level of a guild.
106
    Attributes
107
    ----------
108
    NONE:
109
        Guild has no MFA/2FA requirement for moderation actions.
110
    ELEVATED:
111
        Guild has a 2FA requirement for moderation actions
112
    """
113
114
    NONE = 0
115
    ELEVATED = 1
116
117
118
class VerificationLevel(IntEnum):
119
    """Represents the verification level of a guild.
120
    Attributes
121
    ----------
122
    NONE:
123
        Unrestricted.
124
    LOW:
125
        Must have verified email on account.
126
    MEDIUM:
127
        Must be registered on Discord for longer than 5 minutes.
128
    HIGH:
129
        Must be a member of the server for longer than 10 minutes.
130
    VERY_HIGH:
131
        Must have a verified phone number.
132
    """
133
134
    NONE = 0
135
    LOW = 1
136
    MEDIUM = 2
137
    HIGH = 3
138
    VERY_HIGH = 4
139
140
141
class DefaultMessageNotificationLevel(IntEnum):
142
    """Represents the default message notification level of a guild.
143
    Attributes
144
    ----------
145
    ALL_MESSAGES:
146
        Members will receive notifications for all messages by default.
147
    ONLY_MENTIONS:
148
        Members will receive notifications only for messages that @mention them by default.
149
    """
150
151
    # noqa: E501
152
    ALL_MESSAGES = 0
153
    ONLY_MENTIONS = 1
154
155
156
class SystemChannelFlags(IntEnum):
157
    """Represents the system channel flags of a guild.
158
    Attributes
159
    ----------
160
    SUPPRESS_JOIN_NOTIFICATIONS:
161
        Suppress member join notifications.
162
    SUPPRESS_PREMIUM_SUBSCRIPTIONS:
163
        Suppress server boost notifications.
164
    SUPPRESS_GUILD_REMINDER_NOTIFICATIONS:
165
        Suppress server setup tips.
166
    SUPPRESS_JOIN_NOTIFICATION_REPLIES:
167
        Hide member join sticker reply buttons
168
    """
169
170
    SUPPRESS_JOIN_NOTIFICATIONS = 1 << 0
171
    SUPPRESS_PREMIUM_SUBSCRIPTIONS = 1 << 1
172
    SUPPRESS_GUILD_REMINDER_NOTIFICATIONS = 1 << 2
173
    SUPPRESS_JOIN_NOTIFICATION_REPLIES = 1 << 3
174
175
176
@dataclass(repr=False)
177
class GuildPreview(APIObject):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (10/7)
Loading history...
178
    """Represents a guild preview.
179
    Attributes
180
    ----------
181
    id: :class:`Snowflake`
182
        The guild ID.
183
    name: :class:`str`
184
        The guild name.
185
    icon: :class:`str`
186
        The guild icon hash.
187
    splash: :class:`str`
188
        The guild splash hash.
189
    discovery_splash: :class:`str`
190
        The guild discovery splash hash.
191
    emojis: :class:`List[Emoji]`
192
        The guild emojis.
193
    features: :class:`List[GuildFeature]`
194
        The guild features.
195
    approximate_member_count: :class:`int`
196
        The approximate member count.
197
    approximate_presence_count: :class:`int`
198
        The approximate number of online members in this guild
199
    description: :class:`str`
200
        The guild description.
201
    """
202
203
    id: Snowflake
204
    name: str
205
    emojis: List[Emoji]
206
    features: List[GuildFeature]
207
    approximate_member_count: int
208
    approximate_presence_count: int
209
210
    icon: APINullable[str] = MISSING
211
    splash: APINullable[str] = MISSING
212
    discovery_splash: APINullable[str] = MISSING
213
    description: APINullable[str] = MISSING
214
215
216
@dataclass(repr=False)
217
class Guild(APIObject):
0 ignored issues
show
best-practice introduced by
Too many instance attributes (59/7)
Loading history...
best-practice introduced by
Too many public methods (48/20)
Loading history...
218
    """Represents a Discord guild/server in which your client resides.
219
    Attributes
220
    ----------
221
    afk_channel_id: Optional[:class:`~pincer.utils.snowflake.Snowflake`]
222
        Id of afk channel
223
    afk_timeout: :class:`int`
224
        Afk timeout in seconds
225
    application_id: Optional[:class:`~pincer.utils.snowflake.Snowflake`]
226
        Application id of the guild creator if it is bot-created
227
    banner: Optional[:class:`str`]
228
        Banner hash
229
    default_message_notifications: :class:`~pincer.objects.guild.guild.DefaultMessageNotificationLevel`
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (103/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
230
        Default message notifications level
231
    description: Optional[:class:`str`]
232
        The description of a Community guild
233
    discovery_splash: Optional[:class:`str`]
234
        Discovery splash hash;
235
        only present for guilds with the "DISCOVERABLE" feature
236
    emojis: List[:class:`~pincer.objects.message.emoji.Emoji`]
237
        Custom guild emojis
238
    explicit_content_filter: :class:`~pincer.objects.guild.guild.ExplicitContentFilterLevel`
239
        Explicit content filter level
240
    features: List[:class:`~pincer.objects.guild.features.GuildFeature`]
241
        Enabled guild features
242
    id: :class:`~pincer.utils.snowflake.Snowflake`
243
        Guild id
244
    icon: Optional[:class:`str`]
245
        Icon hash
246
    mfa_level: :class:`~pincer.objects.guild.guild.MFALevel`
247
        Required MFA level for the guild
248
    name: :class:`str`
249
        Guild name (2-100 characters, excluding trailing and leading
250
        whitespace)
251
    nsfw_level: :class:`~pincer.objects.guild.guild.NSFWLevel`
252
        Guild NSFW level
253
    owner_id: :class:`~pincer.utils.snowflake.Snowflake`
254
        Id of owner
255
    preferred_locale: :class:`str`
256
        The preferred locale of a Community guild;
257
        used in server discovery and notices from Discord;
258
        defaults to "en-US"
259
    premium_tier: :class:`~pincer.objects.guild.guild.PremiumTier`
260
        Premium tier (Server Boost level)
261
    public_updates_channel_id: Optional[:class:`~pincer.utils.snowflake.Snowflake`]
262
        The id of the channel where admins
263
        and moderators of Community guilds receive notices from Discord
264
    roles: List[:class:`~pincer.objects.guild.role.Role`]
265
        Roles in the guild
266
    rules_channel_id: Optional[:class:`~pincer.utils.snowflake.Snowflake`]
267
        The id of the channel where Community guilds can display rules
268
        and/or guidelines
269
    splash: Optional[:class:`str`]
270
        Splash hash
271
    system_channel_flags: :class:`~pincer.objects.guild.guild.SystemChannelFlags`
272
        System channel flags
273
    system_channel_id: Optional[:class:`~pincer.utils.snowflake.Snowflake`]
274
        The id of the channel where guild notices
275
        such as welcome messages and boost events are posted
276
    vanity_url_code: Optional[:class:`str`]
277
        The vanity url code for the guild
278
    verification_level: :class:`~pincer.objects.guild.guild.VerificationLevel`
279
        Verification level required for the guild
280
    approximate_member_count: APINullable[:class:`int`]
281
        Approximate number of members in this guild, returned from the
282
        `GET /guilds/<id>` endpoint when with_counts is true
283
    approximate_presence_count: APINullable[:class:`int`]
284
        Approximate number of non-offline members in this guild,
285
        returned from the `GET /guilds/<id>`
286
        endpoint when with_counts is true
287
    channels: APINullable[List[:class:`~pincer.objects.guild.channel.Channel`]]
288
        Channels in the guild
289
    icon_hash: APINullable[Optional[:class:`str`]]
290
        Icon hash, returned when in the template object
291
    joined_at: APINullable[:class:`~pincer.utils.timestamp.Timestamp`]
292
        When this guild was joined at
293
    large: APINullable[:class:`bool`]
294
        True if this is considered a large guild
295
    max_members: APINullable[:class:`int`]
296
        The maximum number of members for the guild
297
    max_presences: APINullable[Optional[:class:`int`]]
298
        The maximum number of presences for the guild
299
        (null is always returned, apart from the largest of guilds)
300
    max_video_channel_users: APINullable[:class:`int`]
301
        The maximum amount of users in a video channel
302
    members: APINullable[List[:class:`~pincer.objects.guild.member.GuildMember`]]
303
        Users in the guild
304
    member_count: APINullable[:class:`bool`]
305
        Total number of members in this guild
306
    nsfw: APINullable[:class:`bool`]
307
        Boolean if the server is NSFW
308
    owner: APINullable[:class:`bool`]
309
        True if the user is the owner of the guild
310
    permissions: APINullable[:class:`str`]
311
        Total permissions for the user in the guild
312
        (excludes overwrites)
313
    premium_subscription_count: APINullable[:class:`int`]
314
        The number of boosts this guild currently has
315
    presences: APINullable[List[:class:`~pincer.objects.events.presence.PresenceUpdateEvent`]]
316
        Presences of the members in the guild,
317
        will only include non-offline members if the size is greater
318
        than large threshold
319
    stage_instances: APINullable[List[:class:`~pincer.objects.guild.stage.StageInstance`]]
320
        Stage instances in the guild
321
    stickers: Optional[List[:class:`~pincer.objects.message.sticker.Sticker`]]
322
        Custom guild stickers
323
    region: APINullable[Optional[:class:`str`]]
324
        Voice region id for the guild (deprecated)
325
    threads: APINullable[List[:class:`~pincer.objects.guild.channel.Channel`]]
326
        All active threads in the guild that current user
327
        has permission to view
328
    unavailable: APINullable[:class:`bool`]
329
        True if this guild is unavailable due to an outage
330
    voice_states: APINullable[List[:class:`~pincer.objects.user.voice_state.VoiceState`]]
331
        States of members currently in voice channels;
332
        lacks the guild_id key
333
    widget_enabled: APINullable[:class:`bool`]
334
        True if the server widget is enabled
335
    widget_channel_id: APINullable[Optional[:class:`~pincer.utils.snowflake.Snowflake`]]
336
        The channel id that the widget will generate an invite to,
337
        or null if set to no invite
338
    welcome_screen: APINullable[:class:`~pincer.objects.guild.welcome_screen.WelcomeScreen`]
339
        The welcome screen of a Community guild, shown to new members,
340
        returned in an Invite's guild object
341
    """
342
343
    # noqa: E501
344
    features: List[GuildFeature]
345
    id: Snowflake
346
    name: str
347
    nsfw_level: GuildNSFWLevel
348
    verification_level: VerificationLevel
349
350
    # Guild invites missing
351
    system_channel_flags: APINullable[SystemChannelFlags] = MISSING
352
    explicit_content_filter: APINullable[ExplicitContentFilterLevel] = MISSING
353
    premium_tier: APINullable[PremiumTier] = MISSING
354
    default_message_notifications: APINullable[
355
        DefaultMessageNotificationLevel
356
    ] = MISSING
357
    mfa_level: APINullable[MFALevel] = MISSING
358
    owner_id: APINullable[Snowflake] = MISSING
359
    afk_timeout: APINullable[int] = MISSING
360
    emojis: APINullable[List[Emoji]] = MISSING
361
    preferred_locale: APINullable[str] = MISSING
362
    roles: APINullable[List[Role]] = MISSING
363
364
    guild_scheduled_events: APINullable[List] = MISSING
365
    lazy: APINullable[bool] = MISSING
366
    premium_progress_bar_enabled: APINullable[bool] = MISSING
367
    guild_hashes: APINullable[Dict] = MISSING
368
    afk_channel_id: APINullable[Snowflake] = MISSING
369
    application_id: APINullable[Snowflake] = MISSING
370
    embedded_activities: APINullable[List] = MISSING
371
    banner: APINullable[str] = MISSING
372
    description: APINullable[str] = MISSING
373
    discovery_splash: APINullable[str] = MISSING
374
    icon: APINullable[str] = MISSING
375
    public_updates_channel_id: APINullable[Snowflake] = MISSING
376
    rules_channel_id: APINullable[Snowflake] = MISSING
377
    splash: APINullable[str] = MISSING
378
    system_channel_id: APINullable[Snowflake] = MISSING
379
    vanity_url_code: APINullable[str] = MISSING
380
381
    application_command_counts: APINullable[Dict] = MISSING
382
    application_command_count: APINullable[int] = MISSING
383
    approximate_member_count: APINullable[int] = MISSING
384
    approximate_presence_count: APINullable[int] = MISSING
385
    channels: APINullable[List[Channel]] = field(default_factory=list)
386
    # TODO: Add type when type is known
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
387
    hub_type: APINullable[Any] = MISSING
388
    icon_hash: APINullable[Optional[str]] = MISSING
389
    joined_at: APINullable[Timestamp] = MISSING
390
    large: APINullable[bool] = MISSING
391
    max_members: APINullable[int] = MISSING
392
    max_presences: APINullable[Optional[int]] = MISSING
393
    max_video_channel_users: APINullable[int] = MISSING
394
    members: APINullable[List[GuildMember]] = MISSING
395
    member_count: APINullable[bool] = MISSING
396
    nsfw: APINullable[bool] = MISSING
397
    # Note: This is missing from discord's docs but in the api
398
    owner: APINullable[bool] = MISSING
399
    permissions: APINullable[str] = MISSING
400
    premium_subscription_count: APINullable[int] = MISSING
401
    presences: APINullable[List[PresenceUpdateEvent]] = MISSING
402
    stage_instances: APINullable[List[StageInstance]] = MISSING
403
    stickers: APINullable[List[Sticker]] = MISSING
404
    region: APINullable[Optional[str]] = MISSING
405
    threads: APINullable[List[Channel]] = MISSING
406
    # Guilds are considered available unless otherwise specified
407
    unavailable: APINullable[bool] = False
408
    voice_states: APINullable[List[VoiceState]] = MISSING
409
    widget_enabled: APINullable[bool] = MISSING
410
    widget_channel_id: APINullable[Optional[Snowflake]] = MISSING
411
    welcome_screen: APINullable[WelcomeScreen] = MISSING
412
413
    @classmethod
414
    async def from_id(cls, client: Client, _id: Union[int, Snowflake]) -> Guild:
415
        """
416
        Parameters
417
        ----------
418
        client : `~pincer.Client`
419
            Client object to use the http gateway from.
420
        _id : :class: `pincer.utils.snowflake.Snowflake`
421
            Guild ID.
422
        Returns
423
        -------
424
        :class: `~pincer.objects.guild.guild.Guild`
425
            The new guild object.
426
        """
427
        data = await client.http.get(f"/guilds/{_id}")
428
        channel_data = await client.http.get(f"/guilds/{_id}/channels")
429
430
        data["channels"]: List[Channel] = [
431
            Channel.from_dict(construct_client_dict(client, i))
432
            for i in (channel_data or [])
433
        ]
434
435
        return Guild.from_dict(construct_client_dict(client, data))
436
437
    async def get_member(self, _id: int) -> GuildMember:
438
        """|coro|
439
        Fetches a GuildMember from its identifier
440
441
        Parameters
442
        ----------
443
        _id: int
444
            The id of the guild member which should be fetched from the Discord
445
            gateway.
446
        Returns
447
        -------
448
        :class:`~pincer.objects.guild.member.GuildMember`
449
            A GuildMember object.
450
        """
451
        return await GuildMember.from_id(self._client, self.id, _id)
452
453
    @overload
454
    async def modify_member(
455
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
456
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
457
        _id: int,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
458
        nick: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
459
        roles: Optional[List[Snowflake]] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
460
        mute: Optional[bool] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
461
        deaf: Optional[bool] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
462
        channel_id: Optional[Snowflake] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
463
    ) -> GuildMember:
464
        """|coro|
465
        Modifies a member in the guild from its identifier and based on the
466
        keyword arguments provided.
467
        Parameters
468
        ----------
469
        _id : int
470
            Id of the member to modify
471
        nick : Optional[:class:`str`]
472
            New nickname for the member |default| :data:`None`
473
        roles : Optional[List[:class:`~pincer.utils.snowflake.Snowflake]]
474
            New roles for the member |default| :data:`None`
475
        mute : Optional[:class:`bool`]
476
            Whether the member is muted |default| :data:`None`
477
        deaf : Optional[:class:`bool`]
478
            Whether the member is deafened |default| :data:`None`
479
        channel_id : Optional[:class:`~pincer.utils.snowflake.Snowflake]
480
            Voice channel id to move to |default| :data:`None`
481
        Returns
482
        -------
483
        :class:`~pincer.objects.guild.member.GuildMember`
484
            The new member object.
485
        """
486
        ...
487
488
    async def modify_member(self, _id: int, **kwargs) -> GuildMember:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
489
        data = await self._http.patch(
490
            f"guilds/{self.id}/members/{_id}", data=kwargs
491
        )
492
        return GuildMember.from_dict(construct_client_dict(self._client, data))
493
494
    async def ban(
495
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
496
        member_id: int,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
497
        reason: str = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
498
        delete_message_days: int = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
499
    ):
500
        """
501
        Parameters
502
        ----------
503
        member_id : :class:`int`
504
            ID of the guild member to ban.
505
        reason : Optional[:class:`str`]
506
            Reason for the kick.
507
        delete_message_days : Optional[:class:`int`]
508
            Number of days to delete messages for (0-7)
509
        """
510
        headers = {}
511
512
        if reason is not None:
513
            headers["X-Audit-Log-Reason"] = reason
514
515
        data = {}
516
517
        if delete_message_days is not None:
518
            data["delete_message_days"] = delete_message_days
519
520
        await self._http.put(
521
            f"/guilds/{self.id}/bans/{member_id}", data=data, headers=headers
522
        )
523
524
    async def kick(self, member_id: int, reason: Optional[str] = None):
525
        """|coro|
526
        Kicks a guild member.
527
        Parameters
528
        ----------
529
        member_id : :class:`int`
530
            ID of the guild member to kick.
531
        reason : Optional[:class:`str`]
532
            Reason for the kick.
533
        """
534
535
        headers = {}
536
537
        if reason is not None:
538
            headers["X-Audit-Log-Reason"] = reason
539
540
        await self._http.delete(
541
            f"/guilds/{self.id}/members/{member_id}", header=headers
542
        )
543
544
    async def get_roles(self) -> AsyncGenerator[Role, None]:
545
        """|coro|
546
        Fetches all the roles in the guild.
547
548
        Yields
549
        -------
550
        AsyncGenerator[:class:`~pincer.objects.guild.role.Role`, :data:`None`]
551
            An async generator of Role objects.
552
        """
553
        data = await self._http.get(f"guilds/{self.id}/roles")
554
        for role_data in data:
555
            yield Role.from_dict(construct_client_dict(self._client, role_data))
556
557
    @overload
558
    async def create_role(
559
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
560
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
561
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
562
        name: Optional[str] = "new role",
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
563
        permissions: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
564
        color: Optional[int] = 0,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
565
        hoist: Optional[bool] = False,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
566
        icon: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
567
        unicode_emoji: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
568
        mentionable: Optional[bool] = False,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
569
    ) -> Role:
570
        """|coro|
571
        Creates a new role for the guild.
572
        Requires the ``MANAGE_ROLES`` permission.
573
574
        Parameters
575
        ----------
576
        reason : Optional[:class:`str`]
577
            Reason for creating the role. |default| :data:`None`
578
        name : Optional[:class:`str`]
579
            name of the role |default| :data:`"new role"`
580
        permissions : Optional[:class:`str`]
581
            bitwise value of the enabled/disabled
582
            permissions, set to @everyone permissions
583
            by default |default| :data:`None`
584
        color : Optional[:class:`int`]
585
            RGB color value |default| :data:`0`
586
        hoist : Optional[:class:`bool`]
587
            whether the role should be displayed
588
            separately in the sidebar |default| :data:`False`
589
        icon : Optional[:class:`str`]
590
            the role's icon image (if the guild has
591
            the ``ROLE_ICONS`` feature) |default| :data:`None`
592
        unicode_emoji : Optional[:class:`str`]
593
            the role's unicode emoji as a standard emoji (if the guild
594
            has the ``ROLE_ICONS`` feature) |default| :data:`None`
595
        mentionable : Optional[:class:`bool`]
596
            whether the role should be mentionable |default| :data:`False`
597
598
        Returns
599
        -------
600
        :class:`~pincer.objects.guild.role.Role`
601
            The new role object.
602
        """
603
        ...
604
605
    async def create_role(self, reason: Optional[str] = None, **kwargs) -> Role:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
606
        return Role.from_dict(
607
            construct_client_dict(
608
                self._client,
609
                await self._http.post(
610
                    f"guilds/{self.id}/roles",
611
                    data=kwargs,
612
                    headers=remove_none({"X-Audit-Log-Reason": reason}),
613
                ),
614
            )
615
        )
616
617
    async def edit_role_position(
618
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
619
        id: Snowflake,
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
620
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
621
        position: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
622
    ) -> AsyncGenerator[Role, None]:
623
        """|coro|
624
        Edits the position of a role.
625
626
        Parameters
627
        ----------
628
        id : :class:`~pincer.utils.snowflake.Snowflake`
629
            The role ID
630
        reason : Optional[:class:`str`]
631
            Reason for editing the role position. |default| :data:`None`
632
        position : Optional[:class:`int`]
633
            Sorting position of the role |default| :data:`None`
634
635
        Yields
636
        -------
637
        AsyncGenerator[:class:`~pincer.objects.guild.role.Role`, :data:`None`]
638
            An async generator of all of the guild's role objects.
639
        """
640
        data = await self._http.patch(
641
            f"guilds/{self.id}/roles",
642
            data={"id": id, "position": position},
643
            headers=remove_none({"X-Audit-Log-Reason": reason}),
644
        )
645
        for role_data in data:
646
            yield Role.from_dict(construct_client_dict(self._client, role_data))
647
648
    @overload
649
    async def edit_role(
650
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
651
        id: Snowflake,
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
652
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
653
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
654
        name: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
655
        permissions: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
656
        color: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
657
        hoist: Optional[bool] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
658
        icon: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
659
        unicode_emoji: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
660
        mentionable: Optional[bool] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
661
    ) -> Role:
662
        """|coro|
663
        Edits a role.
664
        Requires the ``MANAGE_ROLES`` permission.
665
666
        Parameters
667
        ----------
668
        id : :class:`~pincer.utils.snowflake.Snowflake`
669
            The role ID
670
        reason : Optional[:class:`str`]
671
            Reason for editing the role |default| :data:`None`
672
        name : Optional[:class:`str`]
673
            Name of the role |default| :data:`None`
674
        permissions : Optional[:class:`str`]
675
            Bitwise value of the enabled/disabled
676
            permissions |default| :data:`None`
677
        color : Optional[:class:`int`]
678
            RGB color value |default| :data:`None`
679
        hoist : Optional[:class:`bool`]
680
            Whether the role should be displayed
681
            separately in the sidebar |default| :data:`None`
682
        icon : Optional[:class:`str`]
683
            The role's icon image (if the guild has
684
            the ``ROLE_ICONS`` feature) |default| :data:`None`
685
        unicode_emoji : Optional[:class:`str`]
686
            The role's unicode emoji as a standard emoji (if the guild
687
            has the ``ROLE_ICONS`` feature) |default| :data:`None`
688
        mentionable : Optional[:class:`bool`]
689
            Whether the role should be mentionable |default| :data:`None`
690
691
        Returns
692
        -------
693
        :class:`~pincer.objects.guild.role.Role`
694
            The edited role object.
695
        """
696
        ...
697
698
    async def edit_role(
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
699
        self, id: Snowflake, reason: Optional[str] = None, **kwargs
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
700
    ) -> Role:
701
        return Role.from_dict(
702
            construct_client_dict(
703
                self._client,
704
                await self._http.patch(
705
                    f"guilds/{self.id}/roles/{id}",
706
                    data=kwargs,
707
                    headers=remove_none({"X-Audit-Log-Reason": reason}),
708
                ),
709
            )
710
        )
711
712
    async def delete_role(self, id: Snowflake, reason: Optional[str] = None):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
713
        """|coro|
714
        Deletes a role.
715
        Requires the `MANAGE_ROLES` permission.
716
717
        Parameters
718
        ----------
719
        id : :class:`~pincer.utils.snowflake.Snowflake`
720
            The role ID
721
        reason : Optional[:class:`str`]
722
            The reason for deleting the role |default| :data:`None`
723
        """
724
        await self._http.delete(
725
            f"guilds/{self.id}/roles/{id}",
726
            headers=remove_none({"X-Audit-Log-Reason": reason}),
727
        )
728
729
    async def get_bans(self) -> AsyncGenerator[Ban, None]:
730
        """|coro|
731
        Fetches all the bans in the guild.
732
733
        Yields
734
        -------
735
        AsyncGenerator[:class:`~pincer.objects.guild.ban.Ban`, :data:`None`]
736
            An async generator of Ban objects.
737
        """
738
        data = await self._http.get(f"guilds/{self.id}/bans")
739
        for ban_data in data:
740
            yield Ban.from_dict(construct_client_dict(self._client, ban_data))
741
742
    async def get_ban(self, id: Snowflake) -> Ban:
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
743
        """|coro|
744
        Fetches a ban from the guild.
745
746
        Parameters
747
        ----------
748
        id : :class:`~pincer.utils.snowflake.Snowflake`
749
            The user ID
750
751
        Returns
752
        -------
753
        :class:`~pincer.objects.guild.ban.Ban`
754
            The Ban object.
755
        """
756
        return Ban.from_dict(
757
            construct_client_dict(
758
                self._client,
759
                await self._http.get(f"guilds/{self.id}/bans/{id}"),
760
            )
761
        )
762
763
    async def unban(self, id: Snowflake, reason: Optional[str] = None):
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
764
        """|coro|
765
        Unbans a user from the guild.
766
767
        Parameters
768
        ----------
769
        id : :class:`~pincer.utils.snowflake.Snowflake`
770
            The user ID
771
        reason : Optional[:class:`str`]
772
            The reason for unbanning the user |default| :data:`None`
773
        """
774
        await self._http.delete(
775
            f"guilds/{self.id}/bans/{id}",
776
            headers=remove_none({"X-Audit-Log-Reason": reason}),
777
        )
778
779
    @overload
780
    async def edit(
0 ignored issues
show
Comprehensibility introduced by
This function exceeds the maximum number of variables (20/15).
Loading history...
781
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
782
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
783
        name: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
784
        region: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
785
        verification_level: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
786
        default_message_notifications: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
787
        explicit_content_filter: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
788
        afk_channel_id: Optional[Snowflake] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
789
        afk_timeout: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
790
        icon: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
791
        owner_id: Optional[Snowflake] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
792
        splash: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
793
        discovery_splash: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
794
        banner: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
795
        system_channel_id: Optional[Snowflake] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
796
        system_channel_flags: Optional[int] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
797
        rules_channel_id: Optional[Snowflake] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
798
        public_updates_channel_id: Optional[Snowflake] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
799
        preferred_locale: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
800
        features: Optional[List[GuildFeature]] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
801
        description: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
802
    ) -> Guild:
803
        """|coro|
804
        Modifies the guild
805
806
        Parameters
807
        ----------
808
        name : Optional[:class:`str`]
809
            Guild name |default| :data:`None`
810
        region : Optional[:class:`str`]
811
            Guild voice region ID |default| :data:`None`
812
        verification_level : Optional[:class:`int`]
813
            Verification level |default| :data:`None`
814
        default_message_notifications : Optional[:class:`int`]
815
            Default message notification level |default| :data:`None`
816
        explicit_content_filter : Optional[:class:`int`]
817
            Explicit content filter level |default| :data:`None`
818
        afk_channel_id : Optional[:class:`~pincer.utils.snowflake.Snowflake`]
819
            ID for AFK channel |default| :data:`None`
820
        afk_timeout : Optional[:class:`int`]
821
            AFK timeout in seconds |default| :data:`None`
822
        icon : Optional[:class:`str`]
823
            base64 1024x1024 png/jpeg/gif image for the guild icon
824
            (can be animated gif when the server
825
            has the `ANIMATED_ICON` feature) |default| :data:`None`
826
        owner_id : Optional[:class:`~pincer.utils.snowflake.Snowflake`]
827
            User ID to transfer guild ownership to (must be owner) |default| :data:`None`
828
        splash : Optional[:class:`str`]
829
            base64 16:9 png/jpeg image for the guild splash (when the
830
            server has the `INVITE_SPLASH` feature) |default| :data:`None`
831
        discovery_splash : Optional[:class:`str`]
832
            base64 16:9 png/jpeg image for the guild discovery splash
833
            (when the server has the `DISCOVERABLE` feature) |default| :data:`None`
834
        banner : Optional[:class:`str`]
835
            base64 16:9 png/jpeg image for the guild banner (when the
836
            server has the `BANNER` feature) |default| :data:`None`
837
        system_channel_id : Optional[:class:`~pincer.utils.snowflake.Snowflake`]
838
            The ID of the channel where guild notices such as welcome
839
            messages and boost events are posted |default| :data:`None`
840
        system_channel_flags : Optional[:class:`int`]
841
            System channel flags |default| :data:`None`
842
        rules_channel_id : Optional[:class:`~pincer.utils.snowflake.Snowflake`]
843
            The ID of the channel where Community guilds display rules
844
            and/or guidelines |default| :data:`None`
845
        public_updates_channel_id : Optional[:class:`~pincer.utils.snowflake.Snowflake`]
846
            The ID of the channel where admins and moderators of
847
            Community guilds receive notices from Discord |default| :data:`None`
848
        preferred_locale : Optional[:class:`str`]
849
            The preferred locale of a Community guild used in server
850
            discovery and notices from Discord; defaults to "en-US" |default| :data:`None`
851
        features : Optional[List[:class:`GuildFeature`]]
852
            Enabled guild features |default| :data:`None`
853
        description : Optional[:class:`str`]
854
            The description for the guild, if the guild is discoverable |default| :data:`None`
855
856
        Returns
857
        -------
858
        :class:`~pincer.objects.guild.Guild`
859
            The modified guild object.
860
        """
861
        ...
862
863
    async def edit(self, **kwargs) -> Guild:
0 ignored issues
show
introduced by
Missing function or method docstring
Loading history...
864
        g = await self._http.patch(f"guilds/{self.id}", data=kwargs)
865
        return Guild.from_dict(construct_client_dict(self._client, g))
866
867
    async def preview(self) -> GuildPreview:
868
        """|coro|
869
        Previews the guild.
870
871
        Returns
872
        -------
873
        :class:`~pincer.objects.guild.guild.GuildPreview`
874
            The guild preview object.
875
        """
876
        data = await self._http.get(f"guilds/{self.id}/preview")
877
        return GuildPreview.from_dict(data)
878
879
    async def delete(self):
880
        """|coro|
881
        Deletes the guild. Returns `204 No Content` on success.
882
        """
883
        await self._http.delete(f"guilds/{self.id}")
884
885
    async def prune_count(
886
        self, days: Optional[int] = 7, include_roles: Optional[str] = None
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
887
    ) -> int:
888
        """|coro|
889
        Returns the number of members that
890
        would be removed in a prune operation.
891
        Requires the ``KICK_MEMBERS`` permission.
892
893
        Parameters
894
        ----------
895
        days : Optional[:class:`int`]
896
            Number of days to count prune for (1-30) |default| :data:`7`
897
        include_roles : Optional[:class:`str`]
898
            Comma-delimited array of Snowflakes;
899
            role(s) to include |default| :data:`None`
900
901
        Returns
902
        -------
903
        :class:`int`
904
            The number of members that would be removed.
905
        """
906
        return await self._http.get(
907
            f"guilds/{self.id}/prune?{days=}&{include_roles=!s}"
908
        )["pruned"]
909
910
    async def prune(
911
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
912
        days: Optional[int] = 7,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
913
        compute_prune_days: Optional[bool] = True,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
914
        include_roles: Optional[List[Snowflake]] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
915
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
916
    ) -> int:
917
        """|coro|
918
        Prunes members from the guild. Requires the ``KICK_MEMBERS`` permission.
919
920
        Parameters
921
922
        Parameters
923
        ----------
924
        days : Optional[:class:`int`]
925
            Number of days to prune (1-30) |default| :data:`7`
926
        compute_prune_days : Optional[:class:`bool`]
927
            Whether ``pruned`` is returned, discouraged for large guilds
928
            |default| :data:`True`
929
        include_roles : Optional[List[:class:`~pincer.utils.snowflake.Snowflake`]]
930
            role(s) to include |default| :data:`None`
931
        reason : Optional[:class:`str`]
932
            Reason for the prune |default| :data:`None`
933
934
        Returns
935
        -------
936
        :class:`int`
937
            The number of members that were removed.
938
        """
939
        return await self._http.post(
940
            f"guilds/{self.id}/prune",
941
            data={
942
                "days": days,
943
                "compute_prune_days": compute_prune_days,
944
                "include_roles": include_roles,
945
            },
946
            headers=remove_none({"X-Audit-Log-Reason": reason}),
947
        )["pruned"]
948
949
    async def get_voice_regions(self) -> AsyncGenerator[VoiceRegion, None]:
950
        """|coro|
951
        Returns an async generator of voice regions.
952
953
        Yields
954
        -------
955
        AsyncGenerator[:class:`~pincer.objects.voice.VoiceRegion`, :data:`None`]
956
            An async generator of voice regions.
957
        """
958
        data = await self._http.get(f"guilds/{self.id}/regions")
959
        for voice_region_data in data:
960
            yield VoiceRegion.from_dict(
961
                construct_client_dict(self._client, voice_region_data)
962
            )
963
964
    async def get_invites(self) -> AsyncGenerator[Invite, None]:
965
        """|coro|
966
        Returns an async generator of invites for the guild.
967
        Requires the ``MANAGE_GUILD`` permission.
968
969
        Yields
970
        -------
971
        AsyncGenerator[:class:`~pincer.objects.invite.Invite`, :data:`None`]
972
            An async generator of invites.
973
        """
974
        data = await self._http.get(f"guilds/{self.id}/invites")
975
        for invite_data in data:
976
            yield Invite.from_dict(
977
                construct_client_dict(self._client, invite_data)
978
            )
979
980
    async def get_integrations(self) -> AsyncGenerator[Integration, None]:
981
        """|coro|
982
        Returns an async generator of integrations for the guild.
983
        Requires the ``MANAGE_GUILD`` permission.
984
985
        Yields
986
        -------
987
        AsyncGenerator[:class:`~pincer.objects.integration.Integration`, :data:`None`]
988
            An async generator of integrations.
989
        """
990
        data = await self._http.get(f"guilds/{self.id}/integrations")
991
        for integration_data in data:
992
            yield Integration.from_dict(
993
                construct_client_dict(self._client, integration_data)
994
            )
995
996
    async def delete_integration(
997
        self, integration: Integration, reason: Optional[str] = None
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
998
    ):
999
        """|coro|
1000
        Deletes an integration.
1001
        Requires the ``MANAGE_GUILD`` permission.
1002
1003
        Parameters
1004
        ----------
1005
        integration : :class:`~pincer.objects.integration.Integration`
1006
            The integration to delete.
1007
        reason : Optional[:class:`str`]
1008
            Reason for the deletion |default| :data:`None`
1009
        """
1010
        await self._http.delete(
1011
            f"guilds/{self.id}/integrations/{integration.id}",
1012
            headers=remove_none({"X-Audit-Log-Reason": reason}),
1013
        )
1014
1015
    async def get_widget_settings(self) -> GuildWidget:
1016
        """|coro|
1017
        Returns the guild widget settings.
1018
        Requires the ``MANAGE_GUILD`` permission.
1019
1020
        Returns
1021
        -------
1022
        :class:`~pincer.objects.guild.widget.GuildWidget`
1023
            The guild widget settings.
1024
        """
1025
        return GuildWidget.from_dict(
1026
            construct_client_dict(
1027
                self._client, await self._http.get(f"guilds/{self.id}/widget")
1028
            )
1029
        )
1030
1031
    async def modify_widget(
1032
        self, reason: Optional[str] = None, **kwargs
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1033
    ) -> GuildWidget:
1034
        """|coro|
1035
        Modifies the guild widget for the guild.
1036
        Requires the ``MANAGE_GUILD`` permission.
1037
1038
        Parameters
1039
        ----------
1040
        reason : Optional[:class:`str`]
1041
            Reason for the modification |default| :data:`None`
1042
        \\*\\*kwargs
1043
            The widget settings to modify
1044
1045
        Returns
1046
        -------
1047
        :class:`~pincer.objects.guild.widget.GuildWidget`
1048
            The updated GuildWidget object
1049
        """
1050
        data = await self._http.patch(
1051
            f"guilds/{self.id}/widget",
1052
            data=kwargs,
1053
            headers=remove_none({"X-Audit-Log-Reason": reason}),
1054
        )
1055
        return GuildWidget.from_dict(construct_client_dict(self._client, data))
1056
1057
    async def get_widget(self) -> Dict[str, JSONSerializable]:
1058
        """|coro|
1059
        Returns the widget for the guild
1060
        """
1061
        return await self._http.get(f"guilds/{self.id}/widget.json")
1062
1063
    @property
1064
    async def vanity_url(self) -> Invite:
1065
        """|coro|
1066
        Returns the Vanity URL for the guild.
1067
        Requires the ``MANAGE_GUILD`` permission.
1068
        ``code`` will be null if a vanity URL has not been set.
1069
1070
        Returns
1071
        -------
1072
        :class:`~pincer.objects.guild.invite.Invite`
1073
            The vanity url for the guild.
1074
        """
1075
        data = await self._http.get(f"guilds/{self.id}/vanity-url")
1076
        return Invite.from_dict(construct_client_dict(self._client, data))
1077
1078
    async def get_widget_image(
1079
        self, style: Optional[str] = "shield"
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1080
    ) -> str:  # TODO Replace str with ImageURL object
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
1081
        """|coro|
1082
        Returns a PNG image widget for the guild.
1083
        Requires no permissions or authentication.
1084
1085
        Widget Style Options
1086
        -------------------
1087
        * [``shield``](https://discord.com/api/guilds/81384788765712384/widget.png?style=shield)
1088
          shield style widget with Discord icon and guild members online count
1089
        * [``banner1``](https://discord.com/api/guilds/81384788765712384/widget.png?style=banner1)
1090
          large image with guild icon, name and online count.
1091
          "POWERED BY DISCORD" as the footer of the widget
1092
        * [``banner2``](https://discord.com/api/guilds/81384788765712384/widget.png?style=banner2)
1093
          smaller widget style with guild icon, name and online count.
1094
          Split on the right with Discord logo
1095
        * [``banner3``](https://discord.com/api/guilds/81384788765712384/widget.png?style=banner3)
1096
          large image with guild icon, name and online count.
1097
          In the footer, Discord logo on the
1098
          left and "Chat Now" on the right
1099
        * [``banner4``](https://discord.com/api/guilds/81384788765712384/widget.png?style=banner4)
1100
          large Discord logo at the top of the widget.
1101
          Guild icon, name and online count in the middle portion
1102
          of the widget and a "JOIN MY SERVER" button at the bottom
1103
1104
        Parameters
1105
        ----------
1106
        style : Optional[:class:`str`]
1107
            Style of the widget image returned |default| :data:`"shield"`
1108
1109
        Returns
1110
        -------
1111
        :class:`str`
1112
            A PNG image of the guild widget.
1113
        """
1114
        return await self._http.get(f"guilds/{self.id}/widget.png?{style=!s}")
1115
1116
    async def get_welcome_screen(self) -> WelcomeScreen:
1117
        """Returns the welcome screen for the guild.
1118
1119
        Returns
1120
        -------
1121
        :class:`~pincer.objects.guild.welcome_screen.WelcomeScreen`
1122
            The welcome screen for the guild.
1123
        """
1124
        data = await self._http.get(f"guilds/{self.id}/welcome-screen")
1125
        return WelcomeScreen.from_dict(
1126
            construct_client_dict(self._client, data)
1127
        )
1128
1129
    async def modify_welcome_screen(
1130
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1131
        enabled: Optional[bool] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1132
        welcome_channels: Optional[List[WelcomeScreenChannel]] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1133
        description: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1134
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1135
    ) -> WelcomeScreen:
1136
        """|coro|
1137
        Modifies the guild's Welcome Screen.
1138
        Requires the ``MANAGE_GUILD`` permission.
1139
1140
        Parameters
1141
        ----------
1142
        enabled : Optional[:class:`bool`]
1143
            Whether the welcome screen is enabled |default| :data:`None`
1144
        welcome_channels : Optional[List[:class:`~pincer.objects.guild.welcome_screen.WelcomeScreenChannel`]]
0 ignored issues
show
Coding Style introduced by
This line is too long as per the coding-style (109/100).

This check looks for lines that are too long. You can specify the maximum line length.

Loading history...
1145
            Channels linked in the welcome screen and
1146
            their display options |default| :data:`None`
1147
        description : Optional[:class:`str`]
1148
            The server description to show
1149
            in the welcome screen |default| :data:`None`
1150
        reason : Optional[:class:`str`]
1151
            Reason for the modification |default| :data:`None`
1152
1153
        Returns
1154
        -------
1155
        :class:`~pincer.objects.guild.welcome_screen.WelcomeScreen`
1156
            The updated WelcomeScreen object
1157
        """
1158
        data = await self._http.patch(
1159
            f"guilds/{self.id}/welcome-screen",
1160
            data={
1161
                "enabled": enabled,
1162
                "welcome_channels": welcome_channels,
1163
                "description": description,
1164
            },
1165
            headers=remove_none({"X-Audit-Log-Reason": reason}),
1166
        )
1167
        return WelcomeScreen.from_dict(
1168
            construct_client_dict(self._client, data)
1169
        )
1170
1171
    async def modify_current_user_voice_state(
1172
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1173
        channel_id: Snowflake,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1174
        suppress: Optional[bool] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1175
        request_to_speak_timestamp: Optional[Timestamp] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1176
    ):
1177
        """|coro|
1178
        Updates the current user's voice state.
1179
1180
        There are currently several caveats for this endpoint:
1181
        * ``channel_id`` must currently point to a stage channel
1182
        * current user must already have joined ``channel_id``
1183
        * You must have the ``MUTE_MEMBERS`` permission to
1184
          unsuppress yourself. You can always suppress yourself.
1185
        * You must have the ``REQUEST_TO_SPEAK`` permission to request
1186
          to speak. You can always clear your own request to speak.
1187
        * You are able to set ``request_to_speak_timestamp`` to any
1188
          present or future time.
1189
1190
        Parameters
1191
        ----------
1192
        channel_id : :class:`~pincer.utils.snowflake.Snowflake`
1193
            The ID of the channel the user is currently in
1194
        suppress : Optional[:class:`bool`]
1195
            Toggles the user's suppress state |default| :data:`None`
1196
        request_to_speak_timestamp : Optional[:class:`~pincer.utils.timestamp.Timestamp`]
1197
            Sets the user's request to speak
1198
        """
1199
        await self._http.patch(
1200
            f"guilds/{self.id}/voice-states/@me",
1201
            data={
1202
                "channel_id": channel_id,
1203
                "suppress": suppress,
1204
                "request_to_speak_timestamp": request_to_speak_timestamp,
1205
            },
1206
        )
1207
1208
    async def modify_user_voice_state(
1209
        self, user: User, channel_id: Snowflake, suppress: Optional[bool] = None
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1210
    ):
1211
        """|coro|
1212
        Updates another user's voice state.
1213
1214
        There are currently several caveats for this endpoint:
1215
        * ``channel_id`` must currently point to a stage channel
1216
        * User must already have joined ``channel_id``
1217
        * You must have the ``MUTE_MEMBERS`` permission.
1218
          (Since suppression is the only thing that is available currently.)
1219
        * When unsuppressed, non-bot users will have their
1220
          ``request_to_speak_timestamp`` set to the current time.
1221
          Bot users will not.
1222
        * When suppressed, the user will have their
1223
          ``request_to_speak_timestamp`` removed.
1224
1225
        Parameters
1226
        ----------
1227
        user : :class:`~pincer.objects.guild.member.Member`
1228
            The user to update
1229
        channel_id : :class:`~pincer.utils.snowflake.Snowflake`
1230
            The ID of the channel the user is currently in
1231
        suppress : Optional[:class:`bool`]
1232
            Toggles the user's suppress state |default| :data:`None`
1233
        """
1234
        await self._http.patch(
1235
            f"guilds/{self.id}/voice-states/{user.id}",
1236
            data={"channel_id": channel_id, "suppress": suppress},
1237
        )
1238
1239
    async def get_audit_log(self) -> AuditLog:
1240
        """|coro|
1241
        Returns an audit log object for the guild.
1242
        Requires the ``VIEW_AUDIT_LOG`` permission.
1243
1244
        Returns
1245
        -------
1246
        :class:`~pincer.objects.guild.audit_log.AuditLog`
1247
            The audit log object for the guild.
1248
        """
1249
        return AuditLog.from_dict(
1250
            construct_client_dict(
1251
                self._client,
1252
                await self._http.get(f"guilds/{self.id}/audit-logs"),
1253
            )
1254
        )
1255
1256
    async def get_emojis(self) -> AsyncGenerator[Emoji, None]:
1257
        """|coro|
1258
        Returns an async generator of the emojis in the guild.
1259
1260
        Yields
1261
        ------
1262
        :class:`~pincer.objects.guild.emoji.Emoji`
1263
            The emoji object.
1264
        """
1265
        data = await self._http.get(f"guilds/{self.id}/emojis")
1266
        for emoji_data in data:
1267
            yield Emoji.from_dict(
1268
                construct_client_dict(self._client, emoji_data)
1269
            )
1270
1271
    async def get_emoji(self, id: Snowflake) -> Emoji:
0 ignored issues
show
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
1272
        """|coro|
1273
        Returns an emoji object for the given ID.
1274
1275
        Parameters
1276
        ----------
1277
        id : :class:`~pincer.utils.snowflake.Snowflake`
1278
            The ID of the emoji
1279
1280
        Returns
1281
        -------
1282
        :class:`~pincer.objects.guild.emoji.Emoji`
1283
            The emoji object.
1284
        """
1285
        return Emoji.from_dict(
1286
            construct_client_dict(
1287
                self._client,
1288
                await self._http.get(f"guilds/{self.id}/emojis/{id}"),
1289
            )
1290
        )
1291
1292
    async def create_emoji(
0 ignored issues
show
Bug Best Practice introduced by
The default value [] might cause unintended side-effects.

Objects as default values are only created once in Python and not on each invocation of the function. If the default object is modified, this modification is carried over to the next invocation of the method.

# Bad:
# If array_param is modified inside the function, the next invocation will
# receive the modified object.
def some_function(array_param=[]):
    # ...

# Better: Create an array on each invocation
def some_function(array_param=None):
    array_param = array_param or []
    # ...
Loading history...
1293
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1294
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1295
        name: str,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1296
        image: File,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1297
        roles: List[Snowflake] = [],
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1298
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1299
    ) -> Emoji:
1300
        """|coro|
1301
        Creates a new emoji for the guild.
1302
        Requires the ``MANAGE_EMOJIS_AND_STICKERS`` permission.
1303
1304
        Emojis and animated emojis have a maximum file size of 256kb.
1305
        Attempting to upload an emoji larger than this limit will fail.
1306
1307
        Parameters
1308
        ----------
1309
        name : :class:`str`
1310
            Name of the emoji
1311
        image : :class:`~pincer.objects.message.file.File`
1312
            The File for the 128x128 emoji image data
1313
        roles : List[:class:`~pincer.utils.snowflake.Snowflake`]
1314
            Roles allowed to use this emoji |default| :data:`[]`
1315
        reason : Optional[:class:`str`]
1316
            The reason for creating the emoji |default| :data:`None`
1317
1318
        Returns
1319
        -------
1320
        :class:`~pincer.objects.guild.emoji.Emoji`
1321
            The newly created emoji object.
1322
        """
1323
        data = await self._http.post(
1324
            f"guilds/{self.id}/emojis",
1325
            data={"name": name, "image": image.uri, "roles": roles},
1326
            headers=remove_none({"X-Audit-Log-Reason": reason}),
1327
        )
1328
        return Emoji.from_dict(construct_client_dict(self._client, data))
1329
1330
    async def edit_emoji(
1331
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1332
        id: Snowflake,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
1333
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1334
        name: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1335
        roles: Optional[List[Snowflake]] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1336
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1337
    ) -> Emoji:
1338
        """|coro|
1339
        Modifies the given emoji.
1340
        Requires the ``MANAGE_EMOJIS_AND_STICKERS`` permission.
1341
1342
        Parameters
1343
        ----------
1344
        id : :class:`~pincer.utils.snowflake.Snowflake`
1345
            The ID of the emoji
1346
        name : Optional[:class:`str`]
1347
            Name of the emoji |default| :data:`None`
1348
        roles : Optional[List[:class:`~pincer.utils.snowflake.Snowflake`]]
1349
            Roles allowed to use this emoji |default| :data:`None`
1350
        reason : Optional[:class:`str`]
1351
            The reason for editing the emoji |default| :data:`None`
1352
1353
        Returns
1354
        -------
1355
        :class:`~pincer.objects.guild.emoji.Emoji`
1356
            The modified emoji object.
1357
        """
1358
        data = await self._http.patch(
1359
            f"guilds/{self.id}/emojis/{id}",
1360
            data={"name": name, "roles": roles},
1361
            headers=remove_none({"X-Audit-Log-Reason": reason}),
1362
        )
1363
        return Emoji.from_dict(construct_client_dict(self._client, data))
1364
1365
    async def delete_emoji(
1366
        self, id: Snowflake, *, reason: Optional[str] = None
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
Bug Best Practice introduced by
This seems to re-define the built-in id.

It is generally discouraged to redefine built-ins as this makes code very hard to read.

Loading history...
1367
    ):
1368
        """|coro|
1369
        Deletes the given emoji.
1370
        Requires the ``MANAGE_EMOJIS_AND_STICKERS`` permission.
1371
1372
        Parameters
1373
        ----------
1374
        id : :class:`~pincer.utils.snowflake.Snowflake`
1375
            The ID of the emoji
1376
        reason : Optional[:class:`str`]
1377
            The reason for deleting the emoji |default| :data:`None`
1378
        """
1379
        await self._http.delete(
1380
            f"guilds/{self.id}/emojis/{id}",
1381
            headers=remove_none({"X-Audit-Log-Reason": reason}),
1382
        )
1383
1384
    async def get_templates(self) -> AsyncGenerator[GuildTemplate, None]:
1385
        """|coro|
1386
        Returns an async generator of the guild templates.
1387
1388
        Yields
1389
        -------
1390
        AsyncGenerator[:class:`~pincer.objects.guild.template.GuildTemplate`, :data:`None`]
1391
            The guild template object.
1392
        """
1393
        data = await self._http.get(f"guilds/{self.id}/templates")
1394
        for template_data in data:
1395
            yield GuildTemplate.from_dict(
1396
                construct_client_dict(self._client, template_data)
1397
            )
1398
1399
    async def create_template(
1400
        self, name: str, description: Optional[str] = None
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1401
    ) -> GuildTemplate:
1402
        """|coro|
1403
        Creates a new template for the guild.
1404
        Requires the ``MANAGE_GUILD`` permission.
1405
1406
        Parameters
1407
        ----------
1408
        name : :class:`str`
1409
            Name of the template (1-100 characters)
1410
        description : Optional[:class:`str`]
1411
            Description of the template
1412
            (0-120 characters) |default| :data:`None`
1413
        Returns
1414
        -------
1415
        :class:`~pincer.objects.guild.template.GuildTemplate`
1416
            The newly created template object.
1417
        """
1418
        data = await self._http.post(
1419
            f"guilds/{self.id}/templates",
1420
            data={"name": name, "description": description},
1421
        )
1422
        return GuildTemplate.from_dict(
1423
            construct_client_dict(self._client, data)
1424
        )
1425
1426
    async def sync_template(self, template: GuildTemplate) -> GuildTemplate:
1427
        """|coro|
1428
        Syncs the given template.
1429
        Requires the ``MANAGE_GUILD`` permission.
1430
1431
        Parameters
1432
        ----------
1433
        template : :class:`~pincer.objects.guild.template.GuildTemplate`
1434
            The template to sync
1435
1436
        Returns
1437
        -------
1438
        :class:`~pincer.objects.guild.template.GuildTemplate`
1439
            The synced template object.
1440
        """
1441
        data = await self._http.put(
1442
            f"guilds/{self.id}/templates/{template.code}"
1443
        )
1444
        return GuildTemplate.from_dict(
1445
            construct_client_dict(self._client, data)
1446
        )
1447
1448
    async def edit_template(
1449
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1450
        template: GuildTemplate,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1451
        *,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1452
        name: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1453
        description: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1454
    ) -> GuildTemplate:
1455
        """|coro|
1456
        Modifies the template's metadata.
1457
        Requires the ``MANAGE_GUILD`` permission.
1458
1459
        Parameters
1460
        ----------
1461
        template : :class:`~pincer.objects.guild.template.GuildTemplate`
1462
            The template to edit
1463
        name : Optional[:class:`str`]
1464
            Name of the template (1-100 characters)
1465
            |default| :data:`None`
1466
        description : Optional[:class:`str`]
1467
            Description of the template (0-120 characters)
1468
            |default| :data:`None`
1469
1470
        Returns
1471
        -------
1472
        :class:`~pincer.objects.guild.template.GuildTemplate`
1473
            The edited template object.
1474
        """
1475
        data = await self._http.patch(
1476
            f"guilds/{self.id}/templates/{template.code}",
1477
            data={"name": name, "description": description},
1478
        )
1479
        return GuildTemplate.from_dict(
1480
            construct_client_dict(self._client, data)
1481
        )
1482
1483
    async def delete_template(self, template: GuildTemplate) -> GuildTemplate:
1484
        """|coro|
1485
        Deletes the given template.
1486
        Requires the ``MANAGE_GUILD`` permission.
1487
1488
        Parameters
1489
        ----------
1490
        template : :class:`~pincer.objects.guild.template.GuildTemplate`
1491
            The template to delete
1492
1493
        Returns
1494
        -------
1495
        :class:`~pincer.objects.guild.template.GuildTemplate`
1496
            The deleted template object.
1497
        """
1498
        data = await self._http.delete(
1499
            f"guilds/{self.id}/templates/{template.code}"
1500
        )
1501
        return GuildTemplate.from_dict(
1502
            construct_client_dict(self._client, data)
1503
        )
1504
1505
1506
    async def list_stickers(self) -> AsyncIterator[Sticker]:
1507
        """|coro|
1508
        Yields sticker objects for the current guild.
1509
        Includes ``user`` fields if the bot has the ``MANAGE_EMOJIS_AND_STICKERS`` permission.
1510
1511
        Yields
1512
        ------
1513
        :class:`~pincer.objects.message.sticker.Sticker`
1514
            a sticker for the current guild
1515
        """
1516
1517
        for sticker in await self._http.get(f"guild/{self.id}/stickers"):
1518
            yield Sticker.from_dict(sticker)
1519
1520
    async def get_sticker(self, _id: Snowflake) -> Sticker:
1521
        """|coro|
1522
        Returns a sticker object for the current guild and sticker IDs.
1523
        Includes the ``user`` field if the bot has the ``MANAGE_EMOJIS_AND_STICKERS`` permission.
1524
1525
        Parameters
1526
        ----------
1527
        _id : int
1528
            id of the sticker
1529
1530
        Returns
1531
        -------
1532
        :class:`~pincer.objects.message.sticker.Sticker`
1533
            the sticker requested
1534
        """
1535
        sticker = await self._http.get(f"guilds/{self.id}/stickers/{_id}")
1536
        return Sticker.from_dict(sticker)
1537
1538
    async def create_sticker(
0 ignored issues
show
best-practice introduced by
Too many arguments (6/5)
Loading history...
1539
        self,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1540
        name: str,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1541
        tags: str,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1542
        file,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1543
        description: str = "",
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1544
        reason: Optional[str] = None,
0 ignored issues
show
Coding Style introduced by
Wrong hanging indentation before block (add 4 spaces).
Loading history...
1545
    ) -> Sticker:
1546
        """NOT IMPLEMENTED: DOES NOT WORK"""
1547
        raise NotImplementedError
1548
        # TODO: Fix this once File is fixed
0 ignored issues
show
Coding Style introduced by
TODO and FIXME comments should generally be avoided.
Loading history...
1549
        # """|coro|
1550
        # Create a new sticker for the guild.
1551
        # Requires the ``MANAGE_EMOJIS_AND_STICKERS permission``.
1552
        #
1553
        # Parameters
1554
        # ----------
1555
        # name : str
1556
        #     name of the sticker (2-30 characters)
1557
        # tags : str
1558
        #     autocomplete/suggestion tags for the sticker (max 200 characters)
1559
        # file :
1560
        #     the sticker file to upload, must be a PNG, APNG, or Lottie JSON file, max 500 KB
1561
        # description : Optional[:class:`str`]
1562
        #     description of the sticker (empty or 2-100 characters) |default| :data:`""`
1563
        # reason : Optional[:class:`str`] |default| :data:`None`
1564
        #     reason for creating the sticker
1565
        #
1566
        # Returns
1567
        # -------
1568
        # :class:`~pincer.objects.message.sticker.Sticker`
1569
        #     the newly created sticker
1570
        # """
1571
        # sticker = await self._http.post(
1572
        #     f"guilds/{self.id}/stickers",
1573
        #     headers=remove_none({"X-Audit-Log-Reason": reason})
1574
        # )
1575
        #
1576
        # return Sticker.from_dict(sticker)
1577
1578
    async def delete_sticker(self, _id: Snowflake):
1579
        """|coro|
1580
        Delete the given sticker.
1581
        Requires the ``MANAGE_EMOJIS_AND_STICKERS`` permission.
1582
1583
        Parameters
1584
        ----------
1585
        _id: Snowflake
1586
            id of the sticker
1587
        """
1588
        await self._http.delete(f"guilds/{self.id}/stickers/{_id}")
1589
1590
    async def get_webhooks(self) -> AsyncGenerator[Webhook, None]:
1591
        """|coro|
1592
        Returns an async generator of the guild webhooks.
1593
1594
        Yields
1595
        -------
1596
        AsyncGenerator[:class:`~pincer.objects.guild.webhook.Webhook`, None]
1597
            The guild webhook object.
1598
        """
1599
        data = await self._http.get(f"guilds/{self.id}/webhooks")
1600
        for webhook_data in data:
1601
            yield Webhook.from_dict(
1602
                construct_client_dict(self._client, webhook_data)
1603
            )
1604
1605
    @classmethod
1606
    def from_dict(cls, data) -> Guild:
1607
        """
1608
        Parameters
1609
        ----------
1610
        data : :class:`Dict`
1611
            Guild data received from the discord API.
1612
        Returns
1613
        -------
1614
        :class:`~pincer.objects.guild.guild.Guild`
1615
            The new guild object.
1616
        Raises
1617
        ------
1618
        :class:`~pincer.exceptions.UnavailableGuildError`
1619
            The guild is unavailable due to a discord outage.
1620
        """
1621
        if data.get("unavailable", False):
1622
            raise UnavailableGuildError(
1623
                f"Guild \"{data['id']}\" is unavailable due to a discord"
1624
                " outage."
1625
            )
1626
1627
        return super().from_dict(data)
1628
1629
1630
@dataclass(repr=False)
1631
class UnavailableGuild(APIObject):
0 ignored issues
show
introduced by
Missing class docstring
Loading history...
1632
    id: Snowflake
1633
    unavailable: bool = True
1634