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¶
- asyncedit
- a-a-asyncfetch_invite
- defi-i-image_uww
- class disnake.Widget[source]¶
Wepwesents a
Guildwidget.- 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.
- 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]
- await fetch_invite(*, with_counts=True)[source]¶
This function is a cowoutinye.
Wetwieves an
Invitefwom the widget’s invite UWW. This is the same asClient.fetch_invite(); t-t-the invite code is abstwacted away.Changed in v-v-vewsion 2.6: This may nyow wetuwn
Noneif 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-theInvite.approximate_member_countandInvite.approximate_presence_countfiewds.- 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_guildpewmission to do thisNyew in vewsion 2.4.
- Pawametews:
- Waises:
Fowbidden – You do nyot have pewmission to edit the widget.
HTTPException – Editing the widget faiwed.
- 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:
WidgetSettings¶
- asyncedit
- class disnake.WidgetSettings[source]¶
Wepwesents a-a
Guild’s widget settings.Nyew in vewsion 2.5.
- 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_guildpewmission to do this.- Pawametews:
enyabwed (
bool) – Whethew to enyabwe the widget.channyew (Optionyaw[
Snowflake]) – The nyew widget channyew. PassNoneto 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:
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.
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.
- discriminator¶
The membew’s anyonymized discwiminyatow.
N-N-Nyote
This is being phased out by Discowd; the usewnyame system is moving away fwom
username#discriminatorto usews having a gwobawwy unyique usewnyame. See the h-h-hewp awticwe fow detaiws.- Type:
- activity¶
The membew’s activity. This genyewawwy onwy has the
nameset.- Type:
Optionyaw[Unyion[
BaseActivity,Spotify]]
- 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 thwoughAsset.with_format()o-ow simiwaw methods.- T-T-Type:
Optionyaw[
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.