#Send Embed as Ephemeral

1 messages · Page 1 of 1 (latest)

true copper
#

I want to send en embed as ephemeral but idk how.

My Code:

class LimitModal(ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs, timeout=None)

        self.add_item(ui.InputText(
            label="Voice Channel Limit setzen", style=InputTextStyle.short))

    async def callback(self, interaction: Interaction):

        voicechannel = interaction.user.voice.channel
        await voicechannel.edit(user_limit=self.children[0].value)

        embed = Embed(
            title=f"✅ Channel Limit wurde auf {self.children[0].value} Member gesetzt.")
        channel = await interaction.guild.fetch_channel(1087350554977640508)

        await interaction.response.send_message(f"Voice Channel wurde erfolgreich bearbeitet", ephemeral=True)
        await channel.send(embed=embed)
dawn pebble
#

You can't send an ephemeral embed to a channel? Who's the embed going to be visible for?

#

The whole point of ephemeral is that only a user can see them, how would a channel see it?

true copper
true copper
#

i mean on another code snipped i did this

await interaction.followup.send(embed=embed, ephemeral=True)

#

but now i cant do that cause i need to send it into the right channel

dawn pebble
#

You can't send ephemeral messages to any other channel than the interaction happened in. It can't be done without a response or followup

true copper
dawn pebble
#

If what you're trying is to send ephemeral messages out of nowhere in another channel, no, it's not possible

true copper
#

is there any possible to set in a response the channel ?

true copper
dawn pebble
#

So what's wrong with using interaction.response then?

true copper
#

so look, my thats my button calss:

class ChannelSettingsButtonView(ui.View):
    def __init__(self):
        super().__init__(timeout=None)
  @ ui.button(emoji="👥", style=ButtonStyle.primary)
    async def limit_button_callback(self, button, interaction):
        await interaction.response.send_modal(LimitModal(title="Limit"))

and thats my modal class:

class LimitModal(ui.Modal):
    def __init__(self, *args, **kwargs) -> None:
        super().__init__(*args, **kwargs, timeout=None)

        self.add_item(ui.InputText(
            label="Voice Channel Limit setzen", style=InputTextStyle.short))

    async def callback(self, interaction: Interaction):

        voicechannel = interaction.user.voice.channel
        await voicechannel.edit(user_limit=self.children[0].value)

        embed = Embed(
            title=f"✅ Channel Limit wurde auf {self.children[0].value} Member gesetzt.")
        channel = await interaction.guild.fetch_channel(1087350554977640508)

        await interaction.response.send_message(f"Voice Channel wurde erfolgreich bearbeitet", ephemeral=True)
        await channel.send(embed=embed)
#

so in the modal class he doesnt know what channel he should send the message in you know?

queen cloak
#

why fetch channel? use partial objects

#

.tag partial

shadow drumBOT
#

Partial Objects

These can be used to make API calls when you have channel id and/or message id, and you don't want to rely on the cache to have their objects.

Methods which can be used on them are -

Example Usage:

async def star_message(channel_id: int, message_id: int):

    # Get Partial Messageable object. Docs-
    # https://docs.pycord.dev/en/stable/ext/commands/api.html#discord.ext.commands.Bot.get_partial_messageable
    partial_channel = bot.get_partial_messageable(channel_id)

    # Get Partial Message. Docs-
    # https://docs.pycord.dev/en/stable/api/models.html#discord.PartialMessageable.get_partial_message
    partial_message = partial_channel.get_partial_message(message_id)

    # Add a reaction
    await partial_message.add_reaction(":star:")
true copper
dawn pebble
true copper
dawn pebble
true copper
dawn pebble
#

You think?

true copper
dawn pebble
#

Here's a tip, read the docs

true copper
#

i thought i already tested it and it didnt work, but i was wrong

#

thanks :D

dawn pebble
#

.solved

shadow drumBOT
#

Done with your help thread?

Please close your own help thread by using </close:1009144375709814897> with @sharp fiber.

true copper
#

cant close this thread again :/

#

The application did not respond