|
5 | 5 | from discord.ext.commands import CommandError, Context, UserInputError, guild_only
|
6 | 6 |
|
7 | 7 | from PyDrocsid.cog import Cog
|
8 |
| -from PyDrocsid.command import Confirmation, docs, reply |
| 8 | +from PyDrocsid.command import Confirmation, add_reactions, docs, reply |
9 | 9 | from PyDrocsid.converter import Color
|
10 |
| -from PyDrocsid.discohook import create_discohook_link |
| 10 | +from PyDrocsid.discohook import DISCOHOOK_EMPTY_MESSAGE, MessageContent, create_discohook_link, load_discohook_link |
11 | 11 | from PyDrocsid.translations import t
|
12 | 12 | from PyDrocsid.util import check_message_send_permissions, read_complete_message, read_normal_message
|
13 | 13 |
|
@@ -109,6 +109,26 @@ async def send_copy(self, ctx: Context, channel: TextChannel, message: Message):
|
109 | 109 | embed = Embed(title=t.messages, colour=Colors.MessageCommands, description=t.msg_sent)
|
110 | 110 | await reply(ctx, embed=embed)
|
111 | 111 |
|
| 112 | + @send.command(name="discohook", aliases=["dh"]) |
| 113 | + @docs(t.commands.send_discohook(DISCOHOOK_EMPTY_MESSAGE)) |
| 114 | + async def send_discohook(self, ctx: Context, channel: TextChannel, *, discohook_url: str): |
| 115 | + messages: list[MessageContent] = await load_discohook_link(discohook_url) |
| 116 | + |
| 117 | + check_message_send_permissions(channel, check_embed=any(m.embeds for m in messages)) |
| 118 | + |
| 119 | + try: |
| 120 | + for message in messages: |
| 121 | + if message.is_empty: |
| 122 | + continue |
| 123 | + content: str | None = message.content |
| 124 | + for embed in message.embeds or [None]: |
| 125 | + await channel.send(content=content, embed=embed) |
| 126 | + content = None |
| 127 | + except (HTTPException, Forbidden): |
| 128 | + raise CommandError(t.msg_could_not_be_sent) |
| 129 | + |
| 130 | + await add_reactions(ctx.message, "white_check_mark") |
| 131 | + |
112 | 132 | @commands.group()
|
113 | 133 | @MessagePermission.edit.check
|
114 | 134 | @guild_only()
|
|
0 commit comments