MCPcopy
hub / github.com/Rapptz/discord.py / create_guild_sticker

Method create_guild_sticker

discord/http.py:1673–1707  ·  view source on GitHub ↗
(
        self, guild_id: Snowflake, payload: Dict[str, Any], file: File, reason: Optional[str]
    )

Source from the content-addressed store, hash-verified

1671 )
1672
1673 def create_guild_sticker(
1674 self, guild_id: Snowflake, payload: Dict[str, Any], file: File, reason: Optional[str]
1675 ) -> Response[sticker.GuildSticker]:
1676 initial_bytes = file.fp.read(16)
1677
1678 try:
1679 mime_type = utils._get_mime_type_for_image(initial_bytes)
1680 except ValueError:
1681 if initial_bytes.startswith(b'{'):
1682 mime_type = 'application/json'
1683 else:
1684 mime_type = 'application/octet-stream'
1685 finally:
1686 file.reset()
1687
1688 form: List[Dict[str, Any]] = [
1689 {
1690 'name': 'file',
1691 'value': file.fp,
1692 'filename': file.filename,
1693 'content_type': mime_type,
1694 }
1695 ]
1696
1697 for k, v in payload.items():
1698 form.append(
1699 {
1700 'name': k,
1701 'value': v,
1702 }
1703 )
1704
1705 return self.request(
1706 Route('POST', '/guilds/{guild_id}/stickers', guild_id=guild_id), form=form, files=[file], reason=reason
1707 )
1708
1709 def modify_guild_sticker(
1710 self,

Callers 1

create_stickerMethod · 0.80

Calls 5

requestMethod · 0.95
RouteClass · 0.85
itemsMethod · 0.80
readMethod · 0.45
resetMethod · 0.45

Tested by

no test coverage detected