Skip to content

Guild

Guild

Represents a Guild from Discord

Attributes:

Name Type Description
widget GuildWidget

The guild's widget interface

vanity_url GuildVanityURL

The guild's vanity url interface

welcome_screen GuildWelcomeScreen

The guild's welcome screen interface

channels GuildChannelState

The guild's channel state

emojis GuildEmojiState

The guild's emoji state

roles RoleState

The guild's role state

members GuildMemberState

The guild's member state

WelcomeScreen

Represents a Guild's welcome screen

Attributes:

Name Type Description
description str

The welcome screen's description

guild Guild

The guild associated with the welcome screen

welcome_channels list[WelcomeChannel]

The welcome screen's channels

fetch(self) async

Invokes an API request to get the welcome screen

Returns:

Type Description
WelcomeScreen

The updated welcome screen

Source code in snekcord\objects\guildobject.py
async def fetch(self):
    """Invokes an API request to get the welcome screen

    Returns:
        WelcomeScreen: The updated welcome screen
    """
    data = await rest.get_guild_welcome_screen.request(
        session=self.guild.manager.rest,
        fmt=dict(guild_id=self.guild.id))

    self.update(data)

    return self

modify(self, **kwargs) async

Invokes an API request to modify the welcome screen

Parameters:

Name Type Description
enabled bool Whether or not the welcome screen is enabled
welcome_channels dict The new welcome channels {channel: options}
description str The welcome screen's new description

Welcome Channel Options:

Name Description
description The welcome channel's description
emoji The welcome channel's emoji

Returns:

Type Description
WelcomeScreen

The modified welcome screen

Examples:

await guild.welcome_screen.modify(
    description='Welcome to this fantastic guild',
    enabled=True,
    welcome_channels={
        8235356323523452: {
            'description': 'Get roles here',
            'emoji': some_emoji
        },
        7583857293758372: {
            'description': 'Use bot commands here',
            emoji: another_emoji
        }
    }
)
Source code in snekcord\objects\guildobject.py
async def modify(self, **kwargs):
    """Invokes an API request to modify the welcome screen

    **Parameters:**

    | Name             | Type | Description                                   |
    | ---------------- | ---- | --------------------------------------------- |
    | enabled          | bool | Whether or not the welcome screen is enabled  |
    | welcome_channels | dict | The new welcome channels `{channel: options}` |
    | description      | str  | The welcome screen's new description          |

    **Welcome Channel Options:**

    | Name        | Description                       |
    | ----------- | --------------------------------- |
    | description | The welcome channel's description |
    | emoji       | The welcome channel's emoji       |

    Returns:
        WelcomeScreen: The modified welcome screen

    Examples:
        ```py
        await guild.welcome_screen.modify(
            description='Welcome to this fantastic guild',
            enabled=True,
            welcome_channels={
                8235356323523452: {
                    'description': 'Get roles here',
                    'emoji': some_emoji
                },
                7583857293758372: {
                    'description': 'Use bot commands here',
                    emoji: another_emoji
                }
            }
        )
        ```
    """  # noqa: E501
    welcome_channel_keys = WelcomeScreenChannelTemplate.fields

    try:
        welcome_channels = []

        for key, value in kwargs['welcome_channels'].items():
            value['channel_id'] = Snowflake.try_snowflake(key)

            try:
                emoji = value['emoji']
                value['emoji_id'] = emoji.id
                value['emoji_name'] = emoji.name
            except KeyError:
                pass

            _validate_keys(f'welcome_channels[{key}]',
                           value, (), welcome_channel_keys)

            welcome_channels.append(value)
    except KeyError:
        pass

    keys = rest.modify_guild_welcome_screen.json

    _validate_keys(f'{self.__class__.__name__}.modify',
                   kwargs, (), keys)

    data = await rest.modify_guild_welcome_screen.request(
        session=self.guild.manager.rest,
        fmt=dict(guild_id=self.guild.id),
        json=kwargs)

    self.update(data)

    return self

WelcomeScreenChannel

Represents a channel in a WelcomeScreen

Attributes:

Name Type Description
channel_id Snowflake

The id of the channel that this welcome channel refers to

description str

The welcome channel's description

emoji_id Snowflake

The id of the welcome channel's emoji

emoji_name str

The name of the welcome channel's emoji

welcome_screen WelcomeScreen

The welcome screen associated with the welcome channel

channel property readonly

The channel that this welcome channel refers to

Warning

This property relies on the channel cache so it could return None

emoji property readonly

The welcome channel's emoji

Warning

This property relies on the emoji cache to it could return None