Skip to content
This repository was archived by the owner on Oct 2, 2023. It is now read-only.

Commit b9e6115

Browse files
committed
Added send discohook command
1 parent 479389e commit b9e6115

File tree

2 files changed

+25
-2
lines changed

2 files changed

+25
-2
lines changed

moderation/message/cog.py

Lines changed: 22 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5,9 +5,9 @@
55
from discord.ext.commands import CommandError, Context, UserInputError, guild_only
66

77
from PyDrocsid.cog import Cog
8-
from PyDrocsid.command import Confirmation, docs, reply
8+
from PyDrocsid.command import Confirmation, add_reactions, docs, reply
99
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
1111
from PyDrocsid.translations import t
1212
from PyDrocsid.util import check_message_send_permissions, read_complete_message, read_normal_message
1313

@@ -109,6 +109,26 @@ async def send_copy(self, ctx: Context, channel: TextChannel, message: Message):
109109
embed = Embed(title=t.messages, colour=Colors.MessageCommands, description=t.msg_sent)
110110
await reply(ctx, embed=embed)
111111

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+
112132
@commands.group()
113133
@MessagePermission.edit.check
114134
@guild_only()

moderation/message/translations/en.yml

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,9 @@ commands:
99
send_text: send a normal message
1010
send_embed: send an embed
1111
send_copy: copy a message (specify message link)
12+
send_discohook: |
13+
send a discohook message
14+
Go to {}, compose your message, click on `Share Message` and copy the link.
1215
edit: edit messages sent by the bot
1316
edit_text: edit a normal message (specify message link)
1417
edit_embed: edit an embed (specify message link)

0 commit comments

Comments
 (0)