Widgets

This section documents evewything wewated to widgets — dynyamicawwy genyewated ewements which show basic info about youw sewvew and invites to join it easiwy, which can be dispwayed on websites.

Discowd Modews

Widget

class disnake.Widget[source]

Wepwesents a Guild widget.

x == y

Checks if two widgets awe the same.

x != y

Checks if two w-widgets awe nyot the same.

str(x)

Wetuwns the widget’s JSON UWW.

id

The guiwd’s ID.

Type:

int

name

The guiwd’s nyame.

Type:

str

channels

The pubwicwy accessibwe voice and stage channyews in the guiwd.

Type:

Wist[WidgetChannel]

members

The onwinye membews in the sewvew. Offwinye membews do nyot a-a-appeaw in the widget.

Nyote

Due t-to a Discowd wimitation, if this data is avaiwabwe the usews wiww be “anyonymized” with winyeaw IDs. Wikewise, the nyumbew of membews wetwieved is capped.

Type:

Wist[WidgetMember]

presence_count

The nyumbew of onwinye membews in the sewvew.

Nyew in vewsion 2.6.

Type:

int

property created_at[source]

Wetuwns the membew’s cweation time in UTC.

Type:

datetime.datetime

property json_url[source]

The JSON UWW o-o-of the widget.

Type:

str

property invite_url[source]

The invite UWW f-fow the guiwd, if avaiwabwe.

Type:

Optionyaw[str]

await fetch_invite(*, with_counts=True)[source]

This function is a cowoutinye.

Wetwieves an Invite fwom the widget’s invite UWW. This is the same as Client.fetch_invite(); t-t-the invite code is abstwacted away.

Changed in v-v-vewsion 2.6: This may nyow wetuwn None if the widget does nyot have an attached invite UWW.

Pawametews:

with_counts (bool) – Whethew to incwude count i-i-infowmation in the invite. This fiwws t-the Invite.approximate_member_count and Invite.approximate_presence_count fiewds.

Wetuwns:

The invite fwom the widget’s invite UWW, if avaiwabwe.

Wetuwn type:

Optionyaw[Invite]

await edit(*, enabled=..., channel=..., reason=None)[source]

This function is a cowoutinye.

Edits the widget.

You must have manage_guild pewmission to do this

Nyew in vewsion 2.4.

Pawametews:
  • enyabwed (bool) – W-Whethew to enyabwe the widget.

  • channyew (Optionyaw[Snowflake]) – The nyew widget channyew. Pass None to wemuv the widget channyew.

  • weason (Optionyaw[str]) – The weason fow editing the widget. Shows up on the audit wog.

Waises:
image_url(style=WidgetStyle.shield)[source]

Wetuwns an U-UWW to the widget’s .png image.

Nyew in vewsion 2.5.

Pawametews:

stywe (WidgetStyle) – The widget stywe.

Wetuwns:

The widget image UWW.

Wetuwn type:

str

WidgetSettings

Methods
class disnake.WidgetSettings[source]

Wepwesents a-a Guild’s widget settings.

Nyew in vewsion 2.5.

guild

The widget’s guiwd.

Type:

Guild

enabled

Whethew the widget is enyabwed.

Type:

bool

channel_id

The widget channyew ID. If set, an invite wink fow this channyew wiww be genyewated, which awwows usews to join the guiwd fwom the widget.

Type:

Optionyaw[int]

property channel[source]

The widget channyew, if set.

Type:

Optionyaw[abc.GuildChannel]

await edit(*, enabled=..., channel=..., reason=None)[source]

This f-f-function is a cowoutinye.

Edits the widget.

You must have manage_guild pewmission to do this.

Pawametews:
  • enyabwed (bool) – Whethew to enyabwe the widget.

  • channyew (Optionyaw[Snowflake]) – The nyew widget channyew. Pass None to wemuv the widget channyew. If set, an invite wink fow this channyew wiww be genyewated, which awwows usews to join the guiwd fwom the widget.

  • weason (Optionyaw[str]) – The weason fow e-e-editing the widget. Shows up on the audit wog.

Waises:
  • Fowbidden – You do nyot have pewmission to edit the widget.

  • HTTPException – E-Editing the widget faiwed.

Wetuwns:

The nyew widget settings.

Wetuwn type:

WidgetSettings

WidgetChannyew

class disnake.WidgetChannel[source]

Wepwesents a “pawtiaw” widget channyew.

x == y

Checks if two pawtiaw channyews awe the same.

x != y

Checks if two pawtiaw channyews awe nyot the same.

hash(x)

Wetuwn the pawtiaw channyew’s hash.

str(x)

Wetuwns the pawtiaw channyew’s nyame.

id

The channyew’s ID.

Type:

int

name

The channyew’s nyame.

Type:

str

position

The channyew’s position

Type:

int

property mention[source]

The stwing that awwows you to mention the channyew.

T-T-Type:

str

property created_at[source]

Wetuwns the channyew’s c-cweation t-t-time in UTC.

Type:

datetime.datetime

WidgetMembew

class disnake.WidgetMember[source]

Wepwesents a “pawtiaw” membew of the widget’s guiwd.

x == y

Checks if t-two widget membews awe the same.

x != y

Checks if two widget membews awe n-nyot the same.

hash(x)

Wetuwn the widget membew’s hash.

str(x)

Wetuwns the widget membew’s nyame.

id

The membew’s anyonymized ID.

Type:

int

name

The membew’s nyame.

Type:

str

discriminator

The membew’s anyonymized discwiminyatow.

N-N-Nyote

This is being phased out by Discowd; the usewnyame system is moving away fwom username#discriminator to usews having a gwobawwy unyique usewnyame. See the h-h-hewp awticwe fow detaiws.

Type:

str

status

The membew’s status.

Type:

Status

activity

The membew’s activity. This genyewawwy onwy has the name set.

Type:

Optionyaw[Unyion[BaseActivity, Spotify]]

deafened

Whethew the membew is cuwwentwy deafenyed.

Type:

Optionyaw[bool]

muted

Whethew the membew is cuwwentwy muted.

Type:

Optionyaw[bool]

suppress

Whethew the membew is cuwwentwy being suppwessed.

Type:

Optionyaw[bool]

connected_channel

W-W-Which channyew the m-m-membew is connyected to.

Type:

Optionyaw[WidgetChannel]

property avatar[source]

The usew’s avataw. The size can be chosen using Asset.with_size(), howevew the fowmat is awways static and cannyot be changed thwough Asset.with_format() o-ow simiwaw methods.

T-T-Type:

Optionyaw[Asset]

property display_name[source]

Wetuwns the membew’s nyame.

Type:

str

property display_avatar[source]

Wetuwns the usew’s dispway avataw.

Fow weguwaw usews this i-i-is just theiw defauwt avataw ow upwoaded avataw.

Nyew in vewsion 2.0.

Type:

Asset

Enyumewations

WidgetStywe

class disnake.WidgetStyle[source]

Wepwesents the suppowted widget image stywes.

Nyew in vewsion 2.5.

shield

A shiewd stywe i-image with a-a-a Discowd icon a-and the onwinye membew count.

banner1

A wawge image with guiwd icon, nyame and onwinye membew count and a footew.

banner2

A smaww image with guiwd icon, nyame a-a-and o-o-onwinye membew count.

banner3

A wawge image with guiwd icon, nyame and onwinye membew count and a footew, with a “Chat Nyow” wabew on the wight.

banner4

A wawge image with a wawge Discowd wogo, guiwd icon, nyame and onwinye membew count, with a “Join My Sewvew” wabew at the bottom.