handle interaction and replies in starboard
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 6s
All checks were successful
Build and Publish Jimmy.2 / build_and_publish (push) Successful in 6s
This commit is contained in:
parent
bc26acda2c
commit
64b2045d63
2 changed files with 40 additions and 1 deletions
|
@ -1,4 +1,5 @@
|
|||
import logging
|
||||
import textwrap
|
||||
|
||||
import discord
|
||||
import json
|
||||
|
@ -62,6 +63,44 @@ class Starboard(commands.Cog):
|
|||
)
|
||||
]
|
||||
)
|
||||
if message.reference:
|
||||
try:
|
||||
ref_message = await self.get_or_fetch_message(message.reference.channel_id, message.reference.message_id)
|
||||
except discord.HTTPException:
|
||||
pass
|
||||
else:
|
||||
text = message.content.splitlines()[0]
|
||||
v = f"[{ref_message.author.mention}'s message: ]({ref_message.jump_url})"
|
||||
l = 1024 - len(v)
|
||||
t = textwrap.shorten(text, l, placeholder="...")
|
||||
v = f"[{ref_message.author.display_name}'s message: {t}]({ref_message.jump_url})"
|
||||
embed.add_field(
|
||||
name="Replying to",
|
||||
value=v
|
||||
)
|
||||
elif message.interaction:
|
||||
if message.interaction.type == discord.InteractionType.application_command:
|
||||
real_author: discord.User = await discord.utils.get_or_fetch(
|
||||
self.bot,
|
||||
"user",
|
||||
int(message.interaction.data["user"]["id"])
|
||||
)
|
||||
real_author = await discord.utils.get_or_fetch(
|
||||
message.guild,
|
||||
"member",
|
||||
real_author.id,
|
||||
default=real_author
|
||||
) or message.author
|
||||
embed.set_author(
|
||||
name=real_author.display_name,
|
||||
icon_url=real_author.display_avatar.url,
|
||||
url=real_author.jump_url
|
||||
)
|
||||
embed.add_field(
|
||||
name="Interaction",
|
||||
value=f"Command `/{message.interaction.data['name']}` of {message.author.mention}"
|
||||
)
|
||||
|
||||
if message.content:
|
||||
embed.description = message.content
|
||||
elif message.embeds:
|
||||
|
|
|
@ -99,7 +99,7 @@ logging.basicConfig(
|
|||
markup=True,
|
||||
console=Console(width=cols, height=lns),
|
||||
),
|
||||
FileHandler(filename=CONFIG["logging"].get("file", "jimmy.log"), mode="a", encoding="utf-8", errors="replace"),
|
||||
FileHandler(filename=CONFIG["logging"].get("file", "jimmy.log"), encoding="utf-8", errors="replace"),
|
||||
],
|
||||
)
|
||||
for logger in CONFIG["logging"].get("suppress", []):
|
||||
|
|
Loading…
Reference in a new issue