aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorGravatar Daniel Brown <[email protected]>2019-12-05 10:35:55 -0600
committerGravatar Daniel Brown <[email protected]>2019-12-05 10:35:55 -0600
commitad1a33e80152343a81eeeabf0117ced76b83e273 (patch)
tree8042c93172c7eb31846708705ea1be9b656c8457
parentMerge pull request #678 from python-discord/antimalware-paste-url (diff)
Added optional channel parameter to !echo:
- Added the option to specify a channel to have Python repeat what you said to it, as well as keeping the old functionality of having it repeat what you said in the current channel if no channel argument is given. Signed-off-by: Daniel Brown <[email protected]>
-rw-r--r--bot/cogs/bot.py11
1 files changed, 7 insertions, 4 deletions
diff --git a/bot/cogs/bot.py b/bot/cogs/bot.py
index 7583b2f2d..ee0a463de 100644
--- a/bot/cogs/bot.py
+++ b/bot/cogs/bot.py
@@ -4,7 +4,7 @@ import re
import time
from typing import Optional, Tuple
-from discord import Embed, Message, RawMessageUpdateEvent
+from discord import Embed, Message, RawMessageUpdateEvent, TextChannel
from discord.ext.commands import Bot, Cog, Context, command, group
from bot.constants import Channels, DEBUG_MODE, Guild, MODERATION_ROLES, Roles, URLs
@@ -71,9 +71,12 @@ class Bot(Cog):
@command(name='echo', aliases=('print',))
@with_role(*MODERATION_ROLES)
- async def echo_command(self, ctx: Context, *, text: str) -> None:
- """Send the input verbatim to the current channel."""
- await ctx.send(text)
+ async def echo_command(self, ctx: Context, channel: Optional[TextChannel], *, text: str) -> None:
+ """Repeat the given message in either a specified channel or the current channel."""
+ if channel is None:
+ await ctx.send(text)
+ else:
+ await channel.send(text)
@command(name='embed')
@with_role(*MODERATION_ROLES)