Skip to content
Merged
7 changes: 7 additions & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -35,6 +35,13 @@ These changes are available on the `master` branch, but have not yet been releas

### Removed

- Removed guild creation and ownership related methods and arguments as they're not
allowed for bots anymore.
([#3056](https://github.com/Pycord-Development/pycord/pull/3056))
- Removed `Guild.set_mfa_required`, `Guild.delete`, `Template.create_guild` and
`Client.create_guild`.
- Removed the `owner` keyword argument from `Guild.edit`.

## [2.7.0] - 2025-12-24

### Added
Expand Down
49 changes: 0 additions & 49 deletions discord/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -1708,55 +1708,6 @@ async def fetch_guild(self, guild_id: int, /, *, with_counts=True) -> Guild:
data = await self.http.get_guild(guild_id, with_counts=with_counts)
return Guild(data=data, state=self._connection)

async def create_guild(
self,
*,
name: str,
icon: bytes = MISSING,
code: str = MISSING,
) -> Guild:
"""|coro|

Creates a :class:`.Guild`.

Bot accounts in more than 10 guilds are not allowed to create guilds.

Parameters
----------
name: :class:`str`
The name of the guild.
icon: Optional[:class:`bytes`]
The :term:`py:bytes-like object` representing the icon. See :meth:`.ClientUser.edit`
for more details on what is expected.
code: :class:`str`
The code for a template to create the guild with.

.. versionadded:: 1.4

Returns
-------
:class:`.Guild`
The guild created. This is not the same guild that is
added to cache.

Raises
------
:exc:`HTTPException`
Guild creation failed.
:exc:`InvalidArgument`
Invalid icon image format given. Must be PNG or JPG.
"""
if icon is not MISSING:
icon_base64 = utils._bytes_to_base64_data(icon)
else:
icon_base64 = None

if code:
data = await self.http.create_from_template(code, name, icon_base64)
else:
data = await self.http.create_guild(name, icon_base64)
return Guild(data=data, state=self._connection)

async def fetch_stage_instance(self, channel_id: int, /) -> StageInstance:
"""|coro|

Expand Down
52 changes: 1 addition & 51 deletions discord/guild.py
Original file line number Diff line number Diff line change
Expand Up @@ -2082,43 +2082,6 @@ async def leave(self) -> None:
"""
await self._state.http.leave_guild(self.id)

async def delete(self) -> None:
"""|coro|

Deletes the guild. You must be the guild owner to delete the
guild.

Raises
------
HTTPException
Deleting the guild failed.
Forbidden
You do not have permissions to delete the guild.
"""
await self._state.http.delete_guild(self.id)

async def set_mfa_required(self, required: bool, *, reason: str = None) -> None:
"""|coro|

Set whether it is required to have MFA enabled on your account
to perform moderation actions. You must be the guild owner to do this.

Parameters
----------
required: :class:`bool`
Whether MFA should be required to perform moderation actions.
reason: :class:`str`
The reason to show up in the audit log.

Raises
------
HTTPException
The operation failed.
Forbidden
You are not the owner of the guild.
"""
await self._state.http.edit_guild_mfa(self.id, required, reason=reason)

async def edit(
self,
*,
Expand All @@ -2131,7 +2094,6 @@ async def edit(
discovery_splash: bytes | None = MISSING,
community: bool = MISSING,
afk_channel: VoiceChannel | None = MISSING,
owner: Snowflake = MISSING,
afk_timeout: int = MISSING,
default_notifications: NotificationLevel = MISSING,
verification_level: VerificationLevel = MISSING,
Expand Down Expand Up @@ -2195,9 +2157,6 @@ async def edit(
The new channel that is the AFK channel. Could be ``None`` for no AFK channel.
afk_timeout: :class:`int`
The number of seconds until someone is moved to the AFK channel.
owner: :class:`Member`
The new owner of the guild to transfer ownership to. Note that you must
be owner of the guild to do this.
verification_level: :class:`VerificationLevel`
The new verification level for the guild.
default_notifications: :class:`NotificationLevel`
Expand Down Expand Up @@ -2240,8 +2199,7 @@ async def edit(
Editing the guild failed.
InvalidArgument
The image format passed in to ``icon`` is invalid. It must be
PNG or JPG. This is also raised if you are not the owner of the
guild and request an ownership transfer.
PNG or JPG.

Returns
--------
Expand Down Expand Up @@ -2318,14 +2276,6 @@ async def edit(
else:
fields["public_updates_channel_id"] = public_updates_channel.id

if owner is not MISSING:
if self.owner_id != self._state.self_id:
raise InvalidArgument(
"To transfer ownership you must be the owner of the guild."
)

fields["owner_id"] = owner.id

if verification_level is not MISSING:
if not isinstance(verification_level, VerificationLevel):
raise InvalidArgument(
Expand Down
35 changes: 0 additions & 35 deletions discord/http.py
Original file line number Diff line number Diff line change
Expand Up @@ -1498,26 +1498,13 @@ def get_guild(
Route("GET", "/guilds/{guild_id}", guild_id=guild_id), params=params
)

def delete_guild(self, guild_id: Snowflake) -> Response[None]:
return self.request(Route("DELETE", "/guilds/{guild_id}", guild_id=guild_id))

def create_guild(self, name: str, icon: str | None) -> Response[guild.Guild]:
payload = {
"name": name,
}
if icon:
payload["icon"] = icon

return self.request(Route("POST", "/guilds"), json=payload)

def edit_guild(
self, guild_id: Snowflake, *, reason: str | None = None, **fields: Any
) -> Response[guild.Guild]:
valid_keys = (
"name",
"icon",
"afk_timeout",
"owner_id",
"afk_channel_id",
"splash",
"discovery_splash",
Expand All @@ -1543,15 +1530,6 @@ def edit_guild(
reason=reason,
)

def edit_guild_mfa(
self, guild_id: Snowflake, required: bool, *, reason: str | None
) -> Response[guild.GuildMFAModify]:
return self.request(
Route("POST", "/guilds/{guild_id}/mfa", guild_id=guild_id),
json={"level": int(required)},
reason=reason,
)

def get_template(self, code: str) -> Response[template.Template]:
return self.request(Route("GET", "/guilds/templates/{code}", code=code))

Expand Down Expand Up @@ -1608,19 +1586,6 @@ def delete_template(self, guild_id: Snowflake, code: str) -> Response[None]:
)
)

def create_from_template(
self, code: str, name: str, icon: str | None
) -> Response[guild.Guild]:
payload = {
"name": name,
}
if icon:
payload["icon"] = icon

return self.request(
Route("POST", "/guilds/templates/{code}", code=code), json=payload
)

def get_bans(
self,
guild_id: Snowflake,
Expand Down
34 changes: 0 additions & 34 deletions discord/template.py
Original file line number Diff line number Diff line change
Expand Up @@ -168,40 +168,6 @@ def __repr__(self) -> str:
f" creator={self.creator!r} source_guild={self.source_guild!r} is_dirty={self.is_dirty}>"
)

async def create_guild(self, name: str, icon: Any = None) -> Guild:
"""|coro|

Creates a :class:`.Guild` using the template.

Bot accounts in more than 10 guilds are not allowed to create guilds.

Parameters
----------
name: :class:`str`
The name of the guild.
icon: :class:`bytes`
The :term:`py:bytes-like object` representing the icon. See :meth:`.ClientUser.edit`
for more details on what is expected.

Returns
-------
:class:`.Guild`
The guild created. This is not the same guild that is
added to cache.

Raises
------
HTTPException
Guild creation failed.
InvalidArgument
Invalid icon image format given. Must be PNG or JPG.
"""
if icon is not None:
icon = _bytes_to_base64_data(icon)

data = await self._state.http.create_from_template(self.code, name, icon)
return Guild(data=data, state=self._state)

async def sync(self) -> Template:
"""|coro|

Expand Down