Browse Source

Remove reason keyword argument from message deletion.

Apparently this is unsupported.

Affected functions include:

* abc.Messageable.send
* Message.delete
* TextChannel.delete_messages
* TextChannel.purge
pull/725/merge
Rapptz 8 years ago
parent
commit
63231ef033
  1. 7
      discord/abc.py
  2. 22
      discord/channel.py
  3. 9
      discord/message.py

7
discord/abc.py

@ -628,7 +628,7 @@ class Messageable(metaclass=abc.ABCMeta):
raise NotImplementedError raise NotImplementedError
@asyncio.coroutine @asyncio.coroutine
def send(self, content=None, *, tts=False, embed=None, file=None, files=None, reason=None, delete_after=None, nonce=None): def send(self, content=None, *, tts=False, embed=None, file=None, files=None, delete_after=None, nonce=None):
"""|coro| """|coro|
Sends a message to the destination with the content given. Sends a message to the destination with the content given.
@ -664,9 +664,6 @@ class Messageable(metaclass=abc.ABCMeta):
If provided, the number of seconds to wait in the background If provided, the number of seconds to wait in the background
before deleting the message we just sent. If the deletion fails, before deleting the message we just sent. If the deletion fails,
then it is silently ignored. then it is silently ignored.
reason: Optional[str]
The reason for deleting the message, if necessary.
Shows up on the audit log.
Raises Raises
-------- --------
@ -723,7 +720,7 @@ class Messageable(metaclass=abc.ABCMeta):
def delete(): def delete():
yield from asyncio.sleep(delete_after, loop=state.loop) yield from asyncio.sleep(delete_after, loop=state.loop)
try: try:
yield from ret.delete(reason=reason) yield from ret.delete()
except: except:
pass pass
compat.create_task(delete(), loop=state.loop) compat.create_task(delete(), loop=state.loop)

22
discord/channel.py

@ -37,9 +37,9 @@ import asyncio
__all__ = ('TextChannel', 'VoiceChannel', 'DMChannel', 'GroupChannel', '_channel_factory') __all__ = ('TextChannel', 'VoiceChannel', 'DMChannel', 'GroupChannel', '_channel_factory')
@asyncio.coroutine @asyncio.coroutine
def _single_delete_strategy(messages, *, reason): def _single_delete_strategy(messages):
for m in messages: for m in messages:
yield from m.delete(reason=reason) yield from m.delete()
class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable): class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
"""Represents a Discord guild text channel. """Represents a Discord guild text channel.
@ -164,7 +164,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
self._update(self.guild, data) self._update(self.guild, data)
@asyncio.coroutine @asyncio.coroutine
def delete_messages(self, messages, *, reason=None): def delete_messages(self, messages):
"""|coro| """|coro|
Deletes a list of messages. This is similar to :meth:`Message.delete` Deletes a list of messages. This is similar to :meth:`Message.delete`
@ -183,8 +183,6 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
----------- -----------
messages: Iterable[:class:`abc.Snowflake`] messages: Iterable[:class:`abc.Snowflake`]
An iterable of messages denoting which ones to bulk delete. An iterable of messages denoting which ones to bulk delete.
reason: Optional[str]
The reason for bulk deleting these messages. Shows up on the audit log.
Raises Raises
------ ------
@ -211,10 +209,10 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
raise ClientException('Can only bulk delete messages up to 100 messages') raise ClientException('Can only bulk delete messages up to 100 messages')
message_ids = [m.id for m in messages] message_ids = [m.id for m in messages]
yield from self._state.http.delete_messages(self.id, message_ids, reason=reason) yield from self._state.http.delete_messages(self.id, message_ids)
@asyncio.coroutine @asyncio.coroutine
def purge(self, *, limit=100, check=None, before=None, after=None, around=None, reverse=False, reason=None, bulk=True): def purge(self, *, limit=100, check=None, before=None, after=None, around=None, reverse=False, bulk=True):
"""|coro| """|coro|
Purges a list of messages that meet the criteria given by the predicate Purges a list of messages that meet the criteria given by the predicate
@ -246,8 +244,6 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
Same as ``around`` in :meth:`history`. Same as ``around`` in :meth:`history`.
reverse reverse
Same as ``reverse`` in :meth:`history`. Same as ``reverse`` in :meth:`history`.
reason: Optional[str]
The reason for doing this action. Shows up on the audit log.
bulk: bool bulk: bool
If True, use bulk delete. bulk=False is useful for mass-deleting If True, use bulk delete. bulk=False is useful for mass-deleting
a bot's own messages without manage_messages. When True, will fall a bot's own messages without manage_messages. When True, will fall
@ -296,17 +292,17 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
if count >= 2: if count >= 2:
# more than 2 messages -> bulk delete # more than 2 messages -> bulk delete
to_delete = ret[-count:] to_delete = ret[-count:]
yield from strategy(to_delete, reason=reason) yield from strategy(to_delete)
elif count == 1: elif count == 1:
# delete a single message # delete a single message
yield from ret[-1].delete(reason=reason) yield from ret[-1].delete()
return ret return ret
else: else:
if count == 100: if count == 100:
# we've reached a full 'queue' # we've reached a full 'queue'
to_delete = ret[-100:] to_delete = ret[-100:]
yield from strategy(to_delete, reason=reason) yield from strategy(to_delete)
count = 0 count = 0
yield from asyncio.sleep(1) yield from asyncio.sleep(1)
@ -317,7 +313,7 @@ class TextChannel(discord.abc.Messageable, discord.abc.GuildChannel, Hashable):
yield from ret[-1].delete() yield from ret[-1].delete()
elif count >= 2: elif count >= 2:
to_delete = ret[-count:] to_delete = ret[-count:]
yield from strategy(to_delete, reason=reason) yield from strategy(to_delete)
count = 0 count = 0
strategy = _single_delete_strategy strategy = _single_delete_strategy

9
discord/message.py

@ -475,7 +475,7 @@ class Message:
return '{0.author.name} started a call \N{EM DASH} Join the call.'.format(self) return '{0.author.name} started a call \N{EM DASH} Join the call.'.format(self)
@asyncio.coroutine @asyncio.coroutine
def delete(self, *, reason=None): def delete(self):
"""|coro| """|coro|
Deletes the message. Deletes the message.
@ -484,11 +484,6 @@ class Message:
delete other people's messages, you need the :attr:`~Permissions.manage_messages` delete other people's messages, you need the :attr:`~Permissions.manage_messages`
permission. permission.
Parameters
------------
reason: Optional[str]
The reason for deleting this message. Shows up on the audit log.
Raises Raises
------ ------
Forbidden Forbidden
@ -496,7 +491,7 @@ class Message:
HTTPException HTTPException
Deleting the message failed. Deleting the message failed.
""" """
yield from self._state.http.delete_message(self.channel.id, self.id, reason=reason) yield from self._state.http.delete_message(self.channel.id, self.id)
@asyncio.coroutine @asyncio.coroutine
def edit(self, **fields): def edit(self, **fields):

Loading…
Cancel
Save