diff options
| author | Rapptz <[email protected]> | 2016-12-25 17:33:53 -0500 |
|---|---|---|
| committer | Rapptz <[email protected]> | 2017-01-03 09:52:04 -0500 |
| commit | 20ddc9f14fef58d28107631a15ad1445153fa42d (patch) | |
| tree | faa28fffa080c55d6260c1024d98398ed01cde18 /discord/ext/commands/bot.py | |
| parent | [commands] First pass in making commands ext work again. (diff) | |
| download | discord.py-20ddc9f14fef58d28107631a15ad1445153fa42d.tar.xz discord.py-20ddc9f14fef58d28107631a15ad1445153fa42d.zip | |
[commands] Remove send_ utility functions.
Diffstat (limited to 'discord/ext/commands/bot.py')
| -rw-r--r-- | discord/ext/commands/bot.py | 177 |
1 files changed, 0 insertions, 177 deletions
diff --git a/discord/ext/commands/bot.py b/discord/ext/commands/bot.py index 093f4a5d..faa2c109 100644 --- a/discord/ext/commands/bot.py +++ b/discord/ext/commands/bot.py @@ -38,20 +38,6 @@ from .context import Context from .errors import CommandNotFound, CommandError from .formatter import HelpFormatter -def _get_variable(name): - stack = inspect.stack() - try: - for frames in stack: - try: - frame = frames[0] - current_locals = frame.f_locals - if name in current_locals: - return current_locals[name] - finally: - del frame - finally: - del stack - def when_mentioned(bot, msg): """A callable that implements a command prefix equivalent to being mentioned, e.g. ``@bot ``.""" @@ -305,169 +291,6 @@ class Bot(GroupMixin, discord.Client): print('Ignoring exception in command {}'.format(context.command), file=sys.stderr) traceback.print_exception(type(exception), exception, exception.__traceback__, file=sys.stderr) - # utility "send_*" functions - - @asyncio.coroutine - def _augmented_msg(self, coro, **kwargs): - msg = yield from coro - delete_after = kwargs.get('delete_after') - if delete_after is not None: - @asyncio.coroutine - def delete(): - yield from asyncio.sleep(delete_after, loop=self.loop) - yield from self.delete_message(msg) - - discord.compat.create_task(delete(), loop=self.loop) - - return msg - - def say(self, *args, **kwargs): - """|coro| - - A helper function that is equivalent to doing - - .. code-block:: python - - self.send_message(message.channel, *args, **kwargs) - - The following keyword arguments are "extensions" that augment the - behaviour of the standard wrapped call. - - Parameters - ------------ - delete_after: float - Number of seconds to wait before automatically deleting the - message. - - See Also - --------- - :meth:`Client.send_message` - """ - destination = _get_variable('_internal_channel') - - extensions = ('delete_after',) - params = { - k: kwargs.pop(k, None) for k in extensions - } - - coro = self.send_message(destination, *args, **kwargs) - return self._augmented_msg(coro, **params) - - def whisper(self, *args, **kwargs): - """|coro| - - A helper function that is equivalent to doing - - .. code-block:: python - - self.send_message(message.author, *args, **kwargs) - - The following keyword arguments are "extensions" that augment the - behaviour of the standard wrapped call. - - Parameters - ------------ - delete_after: float - Number of seconds to wait before automatically deleting the - message. - - See Also - --------- - :meth:`Client.send_message` - """ - destination = _get_variable('_internal_author') - - extensions = ('delete_after',) - params = { - k: kwargs.pop(k, None) for k in extensions - } - - coro = self.send_message(destination, *args, **kwargs) - return self._augmented_msg(coro, **params) - - def reply(self, content, *args, **kwargs): - """|coro| - - A helper function that is equivalent to doing - - .. code-block:: python - - msg = '{0.mention}, {1}'.format(message.author, content) - self.send_message(message.channel, msg, *args, **kwargs) - - The following keyword arguments are "extensions" that augment the - behaviour of the standard wrapped call. - - Parameters - ------------ - delete_after: float - Number of seconds to wait before automatically deleting the - message. - - See Also - --------- - :meth:`Client.send_message` - """ - author = _get_variable('_internal_author') - destination = _get_variable('_internal_channel') - fmt = '{0.mention}, {1}'.format(author, str(content)) - - extensions = ('delete_after',) - params = { - k: kwargs.pop(k, None) for k in extensions - } - - coro = self.send_message(destination, fmt, *args, **kwargs) - return self._augmented_msg(coro, **params) - - def upload(self, *args, **kwargs): - """|coro| - - A helper function that is equivalent to doing - - .. code-block:: python - - self.send_file(message.channel, *args, **kwargs) - - The following keyword arguments are "extensions" that augment the - behaviour of the standard wrapped call. - - Parameters - ------------ - delete_after: float - Number of seconds to wait before automatically deleting the - message. - - See Also - --------- - :meth:`Client.send_file` - """ - destination = _get_variable('_internal_channel') - - extensions = ('delete_after',) - params = { - k: kwargs.pop(k, None) for k in extensions - } - - coro = self.send_file(destination, *args, **kwargs) - return self._augmented_msg(coro, **params) - - def type(self): - """|coro| - - A helper function that is equivalent to doing - - .. code-block:: python - - self.send_typing(message.channel) - - See Also - --------- - The :meth:`Client.send_typing` function. - """ - destination = _get_variable('_internal_channel') - return self.send_typing(destination) - # global check registration def check(self, func): |